( manifest: McpbManifest, prefix?: 'local.unpacked' | 'local.dxt', )
| 65 | * Uses the same algorithm as the directory backend for consistency. |
| 66 | */ |
| 67 | export function generateExtensionId( |
| 68 | manifest: McpbManifest, |
| 69 | prefix?: 'local.unpacked' | 'local.dxt', |
| 70 | ): string { |
| 71 | const sanitize = (str: string) => |
| 72 | str |
| 73 | .toLowerCase() |
| 74 | .replace(/\s+/g, '-') |
| 75 | .replace(/[^a-z0-9-_.]/g, '') |
| 76 | .replace(/-+/g, '-') |
| 77 | .replace(/^-+|-+$/g, '') |
| 78 | |
| 79 | const authorName = manifest.author.name |
| 80 | const extensionName = manifest.name |
| 81 | |
| 82 | const sanitizedAuthor = sanitize(authorName) |
| 83 | const sanitizedName = sanitize(extensionName) |
| 84 | |
| 85 | return prefix |
| 86 | ? `${prefix}.${sanitizedAuthor}.${sanitizedName}` |
| 87 | : `${sanitizedAuthor}.${sanitizedName}` |
| 88 | } |
| 89 |
nothing calls this directly
no test coverage detected