Function
packageSourceUrl
(
registry: string,
name: string,
)
Source from the content-addressed store, hash-verified
| 89 | |
| 90 | /** Return the canonical web URL for a package on its registry. */ |
| 91 | export function packageSourceUrl( |
| 92 | registry: string, |
| 93 | name: string, |
| 94 | ): string | undefined { |
| 95 | switch (registry) { |
| 96 | case 'npm': |
| 97 | return `https://www.npmjs.com/package/${name}`; |
| 98 | case 'pypi': |
| 99 | return `https://pypi.org/project/${name}/`; |
| 100 | case 'go': |
| 101 | return `https://pkg.go.dev/${name}`; |
| 102 | case 'crates': |
| 103 | return `https://crates.io/crates/${name}`; |
| 104 | case 'rubygems': |
| 105 | return `https://rubygems.org/gems/${name}`; |
| 106 | default: |
| 107 | return undefined; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // --------------------------------------------------------------------------- |
| 112 | // package.json |
Tested by
no test coverage detected