(url: string)
| 13 | * - /reference -> /reference (not an integration, unchanged) |
| 14 | */ |
| 15 | export function normalizeUrl(url: string): string { |
| 16 | if (!url) return url; |
| 17 | |
| 18 | const segments = url.split("/").filter(Boolean); |
| 19 | |
| 20 | if (segments[0] === "integrations" && segments.length > 1) { |
| 21 | const integrationId = segments[1]; |
| 22 | const knownSlugs = new Set(getIntegrations().map((i) => i.slug)); |
| 23 | |
| 24 | if (knownSlugs.has(integrationId)) { |
| 25 | const restOfPath = segments.slice(2).join("/"); |
| 26 | const normalized = `/${integrationId}${ |
| 27 | restOfPath ? "/" + restOfPath : "" |
| 28 | }`; |
| 29 | return normalized === "/" ? "/" : normalized.replace(/\/$/, ""); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return url === "/" ? "/" : url.replace(/\/$/, ""); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Normalizes pathnames for analytics tracking. |
no test coverage detected
searching dependent graphs…