export const PRODUCT_NAME = "MikrotikManager" export const LEGACY_PRODUCT_NAME = "RouterLists" export function hasManagedCommentPrefix(comment: string): boolean { const value = comment.trim() return value.startsWith(`${PRODUCT_NAME}:`) || value.startsWith(`${LEGACY_PRODUCT_NAME}:`) } export function hasManagedRecursiveComment(comment: string): boolean { const value = comment.trim() return ( value.startsWith(`${PRODUCT_NAME}:recursive`) || value.startsWith(`${LEGACY_PRODUCT_NAME}:recursive`) ) } export function managedComment(label: string): string { return `${PRODUCT_NAME}: ${label}` } export function managedRecursiveComment(comment?: string | null): string { const stripped = stripManagedRecursiveComment(comment ?? "") return stripped ? `${PRODUCT_NAME}:recursive ${stripped}` : `${PRODUCT_NAME}:recursive` } const LEGACY_RECURSIVE_PREFIX = /^recursive:\s*/i export function stripManagedRecursiveComment(comment: string): string { const value = comment.trim() if (!value) return "" const managedPrefixes = [ `${PRODUCT_NAME}:recursive`, `${LEGACY_PRODUCT_NAME}:recursive`, ] for (const prefix of managedPrefixes) { if (value.startsWith(prefix)) return value.slice(prefix.length).trim() } if (LEGACY_RECURSIVE_PREFIX.test(value)) { return value.replace(LEGACY_RECURSIVE_PREFIX, "").trim() } return value } /** Owned recursive route: MM/legacy prefix or old `recursive:` mask. */ export function isOwnedRecursiveComment(comment: string | undefined): boolean { if (!comment) return false const value = comment.trim() return hasManagedRecursiveComment(value) || LEGACY_RECURSIVE_PREFIX.test(value) }