[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: support `/package@version` url pattern (#107)

authored by

Anthony Fu and committed by
GitHub
61b7a447 b607f69e

+14 -1
+14 -1
app/pages/[...package].vue
··· 17 17 // /nuxt/v/4.2.0 → packageName: "nuxt", requestedVersion: "4.2.0" 18 18 // /@nuxt/kit → packageName: "@nuxt/kit", requestedVersion: null 19 19 // /@nuxt/kit/v/1.0.0 → packageName: "@nuxt/kit", requestedVersion: "1.0.0" 20 + // /axios@1.13.3 → packageName: "axios", requestedVersion: "1.13.3" 21 + // /@nuxt/kit@1.0.0 → packageName: "@nuxt/kit", requestedVersion: "1.0.0" 20 22 const parsedRoute = computed(() => { 21 23 const segments = route.params.package || [] 22 24 ··· 29 31 } 30 32 } 31 33 34 + // Parse @ versioned package 35 + const fullPath = segments.join('/') 36 + const versionMatch = fullPath.match(/^(@[^/]+\/[^/]+|[^/]+)@([^/]+)$/) 37 + if (versionMatch) { 38 + const [, packageName, requestedVersion] = versionMatch as [string, string, string] 39 + return { 40 + packageName, 41 + requestedVersion, 42 + } 43 + } 44 + 32 45 return { 33 - packageName: segments.join('/'), 46 + packageName: fullPath, 34 47 requestedVersion: null as string | null, 35 48 } 36 49 })