MCPcopy
hub / github.com/webpack/webpack / getSourceMappingURL

Function getSourceMappingURL

lib/util/extractSourceMap.js:48–68  ·  view source on GitHub ↗

* Extract source mapping URL from code comments * @param {string} code source code content * @returns {SourceMappingURL} source mapping information

(code)

Source from the content-addressed store, hash-verified

46 * @returns {SourceMappingURL} source mapping information
47 */
48function getSourceMappingURL(code) {
49 const lines = code.split(/^/m);
50 /** @type {RegExpMatchArray | null | undefined} */
51 let match;
52
53 for (let i = lines.length - 1; i >= 0; i--) {
54 match = lines[i].match(sourceMappingURLRegex);
55 if (match) {
56 break;
57 }
58 }
59
60 const sourceMappingURL = match ? match[1] || match[2] || "" : "";
61
62 return {
63 sourceMappingURL: sourceMappingURL
64 ? decodeURI(sourceMappingURL)
65 : sourceMappingURL,
66 replacementString: match ? match[0] : ""
67 };
68}
69
70/**
71 * Get absolute path for source file

Callers 2

extractSourceMapFunction · 0.85

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected