(path: string)
| 668 | * encodePathLikeUrl('/path/already%20encoded') // '/path/already%20encoded' (preserved) |
| 669 | */ |
| 670 | export function encodePathLikeUrl(path: string): string { |
| 671 | // Encode whitespace and non-ASCII characters that browsers encode in URLs |
| 672 | |
| 673 | // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ASCII range check |
| 674 | // eslint-disable-next-line no-control-regex |
| 675 | if (!/\s|[^\u0000-\u007F]/.test(path)) return path |
| 676 | // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ASCII range check |
| 677 | // eslint-disable-next-line no-control-regex |
| 678 | return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent) |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * Builds the dev-mode CSS styles URL for route-scoped CSS collection. |
no test coverage detected