[READ-ONLY] a fast, modern browser for the npm registry
at main 24 lines 471 B view raw
1import type { RouteLocationRaw } from 'vue-router' 2 3export function packageRoute(packageName: string, version?: string | null): RouteLocationRaw { 4 const [org, name = ''] = packageName.startsWith('@') ? packageName.split('/') : ['', packageName] 5 6 if (version) { 7 return { 8 name: 'package-version', 9 params: { 10 org, 11 name, 12 version, 13 }, 14 } 15 } 16 17 return { 18 name: 'package', 19 params: { 20 org, 21 name, 22 }, 23 } 24}