MCPcopy
hub / github.com/vitejs/vite / normalizeGitUrl

Function normalizeGitUrl

packages/vite/rollupLicensePlugin.ts:185–204  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

183}
184
185function normalizeGitUrl(url: string): string {
186 url = url
187 .replace(/^git\+/, '')
188 .replace(/\.git$/, '')
189 .replace(/(^|\/)[^/]+?@/, '$1') // remove "user@" from "ssh://user@host.com:..."
190 .replace(/(\.[^.]+?):/, '$1/') // change ".com:" to ".com/" from "ssh://user@host.com:..."
191 .replace(/^git:\/\//, 'https://')
192 .replace(/^ssh:\/\//, 'https://')
193 if (url.startsWith('github:')) {
194 return `https://github.com/${url.slice(7)}`
195 } else if (url.startsWith('gitlab:')) {
196 return `https://gitlab.com/${url.slice(7)}`
197 } else if (url.startsWith('bitbucket:')) {
198 return `https://bitbucket.org/${url.slice(10)}`
199 } else if (!url.includes(':') && url.split('/').length === 2) {
200 return `https://github.com/${url}`
201 } else {
202 return url.includes('://') ? url : `https://${url}`
203 }
204}

Callers 1

getDependencyInformationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected