(pathname: string)
| 1 | export function parsePackagePathname(pathname: string): { |
| 2 | package: string; |
| 3 | scope?: string; |
| 4 | version?: string; |
| 5 | filename?: string; |
| 6 | } | null { |
| 7 | try { |
| 8 | pathname = decodeURIComponent(pathname); |
| 9 | } catch (e) { |
| 10 | console.error(`Failed to decode pathname: ${pathname}`); |
| 11 | } |
| 12 | |
| 13 | let match = /^\/((?:(@[^/@]+)\/)?[^/@]+)(?:@([^/]+))?(\/.*)?$/.exec(pathname); |
| 14 | |
| 15 | if (match == null) return null; |
| 16 | |
| 17 | return { |
| 18 | package: match[1], |
| 19 | scope: match[2], |
| 20 | version: match[3], |
| 21 | filename: match[4], |
| 22 | }; |
| 23 | } |
no outgoing calls
no test coverage detected