MCPcopy
hub / github.com/webpack/webpack / getCommithash

Function getCommithash

lib/sharing/utils.js:161–183  ·  view source on GitHub ↗

* extract commit hash from parsed url * @param {URL} urlParsed parsed url * @returns {string} commithash

(urlParsed)

Source from the content-addressed store, hash-verified

159 * @returns {string} commithash
160 */
161function getCommithash(urlParsed) {
162 let { hostname, pathname, hash } = urlParsed;
163 hostname = hostname.replace(/^www\./, "");
164
165 try {
166 hash = decodeURIComponent(hash);
167 // eslint-disable-next-line no-empty
168 } catch (_err) {}
169
170 if (
171 extractCommithashByDomain[
172 /** @type {keyof extractCommithashByDomain} */ (hostname)
173 ]
174 ) {
175 return (
176 extractCommithashByDomain[
177 /** @type {keyof extractCommithashByDomain} */ (hostname)
178 ](pathname, hash) || ""
179 );
180 }
181
182 return hash;
183}
184
185/**
186 * make url right for URL parse

Callers 1

getGitUrlVersionFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected