mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 01:00:41 +00:00
25 lines
590 B
TypeScript
25 lines
590 B
TypeScript
import { normalizeOptionalString } from "../shared/string-coerce.js";
|
|
|
|
export function normalizePackageTagInput(
|
|
value: string | undefined | null,
|
|
packageNames: readonly string[],
|
|
): string | null {
|
|
const trimmed = normalizeOptionalString(value);
|
|
if (!trimmed) {
|
|
return null;
|
|
}
|
|
|
|
for (const packageName of packageNames) {
|
|
if (trimmed === packageName) {
|
|
return null;
|
|
}
|
|
const prefix = `${packageName}@`;
|
|
if (trimmed.startsWith(prefix)) {
|
|
const tag = trimmed.slice(prefix.length).trim();
|
|
return tag ? tag : null;
|
|
}
|
|
}
|
|
|
|
return trimmed;
|
|
}
|