MCPcopy
hub / github.com/webpack/webpack / correctProtocol

Function correctProtocol

lib/sharing/utils.js:201–213  ·  view source on GitHub ↗

* make url protocol right for URL parse * @param {string} gitUrl git url * @returns {string} fixed url

(gitUrl)

Source from the content-addressed store, hash-verified

199 * @returns {string} fixed url
200 */
201function correctProtocol(gitUrl) {
202 // eg: github:foo/bar#v1.0. Should not add double slash, in case of error parsed `pathname`
203 if (RE_GIT_URL_SHORT.test(gitUrl)) {
204 return gitUrl;
205 }
206
207 // eg: user@github.com:foo/bar
208 if (!RE_CUSTOM_PROTOCOL.test(gitUrl)) {
209 return `${DEF_GIT_PROTOCOL}${gitUrl}`;
210 }
211
212 return gitUrl;
213}
214
215/**
216 * extract git dep version from hash

Callers 1

getGitUrlVersionFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected