MCPcopy Index your code
hub / github.com/nodejs/node / extractSourceURLMagicComment

Function extractSourceURLMagicComment

lib/internal/source_map/source_map_cache.js:105–121  ·  view source on GitHub ↗

* Extracts the source url from the content if present. For example * //# sourceURL=file:///path/to/file * * Read more at: https://tc39.es/source-map-spec/#linking-evald-code-to-named-generated-code * @param {string} content - source content * @returns {string | null} source url or null if not p

(content)

Source from the content-addressed store, hash-verified

103 * @returns {string | null} source url or null if not present
104 */
105function extractSourceURLMagicComment(content) {
106 let match;
107 let matchSourceURL;
108 // A while loop is used here to get the last occurrence of sourceURL.
109 // This is needed so that we don't match sourceURL in string literals.
110 while ((match = RegExpPrototypeExec(kSourceURLMagicComment, content))) {
111 matchSourceURL = match;
112 }
113 if (matchSourceURL == null) {
114 return null;
115 }
116 let sourceURL = matchSourceURL.groups.sourceURL;
117 if (sourceURL != null && RegExpPrototypeExec(kLeadingProtocol, sourceURL) === null) {
118 sourceURL = pathToFileURL(sourceURL).href;
119 }
120 return sourceURL;
121}
122
123/**
124 * Extracts the source map url from the content if present. For example

Callers 1

Calls 1

pathToFileURLFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…