mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 11:00:50 +00:00
refactor(shared): centralize @/# slug normalization
This commit is contained in:
@@ -15,3 +15,14 @@ export function normalizeHyphenSlug(raw?: string | null) {
|
||||
const cleaned = dashed.replace(/[^a-z0-9#@._+-]+/g, "-");
|
||||
return cleaned.replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
||||
}
|
||||
|
||||
export function normalizeAtHashSlug(raw?: string | null) {
|
||||
const trimmed = raw?.trim().toLowerCase() ?? "";
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
const withoutPrefix = trimmed.replace(/^[@#]+/, "");
|
||||
const dashed = withoutPrefix.replace(/[\s_]+/g, "-");
|
||||
const cleaned = dashed.replace(/[^a-z0-9-]+/g, "-");
|
||||
return cleaned.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user