* Normalize URL for consistent hashing. * - Converts to lowercase * - Removes trailing slashes * - Removes query parameters and fragments
(url: string)
| 224 | * - Removes query parameters and fragments |
| 225 | */ |
| 226 | function normalizeUrlForHashing(url: string): string { |
| 227 | try { |
| 228 | const parsed = new URL(url) |
| 229 | const normalized = `${parsed.origin}${parsed.pathname}`.toLowerCase().replace(/\/+$/, '') |
| 230 | return normalized |
| 231 | } catch { |
| 232 | return url.toLowerCase().trim().replace(/\/+$/, '') |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Simple deterministic hash function that produces an 8-character hex string. |
no test coverage detected