(p?: string)
| 19 | // Strip the query string and (in the extension build, where `webappUrl` is |
| 20 | // absolute) the host so candidate URLs and `router.asPath` compare uniformly. |
| 21 | export const normalizePath = (p?: string): string => { |
| 22 | let path = p?.split('?')[0] || ''; |
| 23 | if (/^https?:\/\//.test(path)) { |
| 24 | try { |
| 25 | path = new URL(path).pathname; |
| 26 | } catch { |
| 27 | // fall through with the original string |
| 28 | } |
| 29 | } |
| 30 | if (!path || path === '/') { |
| 31 | return path; |
| 32 | } |
| 33 | return path.replace(/\/$/, ''); |
| 34 | }; |
| 35 | |
| 36 | type Matchable = { |
| 37 | id: string; |
no test coverage detected