diff options
Diffstat (limited to 'node_modules/source-map/lib/util.js')
| -rw-r--r-- | node_modules/source-map/lib/util.js | 83 |
1 files changed, 6 insertions, 77 deletions
diff --git a/node_modules/source-map/lib/util.js b/node_modules/source-map/lib/util.js index 3ca92e56..44e0e452 100644 --- a/node_modules/source-map/lib/util.js +++ b/node_modules/source-map/lib/util.js @@ -26,7 +26,7 @@ function getArg(aArgs, aName, aDefaultValue) { } exports.getArg = getArg; -var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; +var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/; var dataUrlRegexp = /^data:.+\,.+$/; function urlParse(aUrl) { @@ -182,7 +182,7 @@ function join(aRoot, aPath) { exports.join = join; exports.isAbsolute = function (aPath) { - return aPath.charAt(0) === '/' || urlRegexp.test(aPath); + return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp); }; /** @@ -302,7 +302,7 @@ function isProtoString(s) { * stubbed out mapping. */ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { - var cmp = strcmp(mappingA.source, mappingB.source); + var cmp = mappingA.source - mappingB.source; if (cmp !== 0) { return cmp; } @@ -327,7 +327,7 @@ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { return cmp; } - return strcmp(mappingA.name, mappingB.name); + return mappingA.name - mappingB.name; } exports.compareByOriginalPositions = compareByOriginalPositions; @@ -351,7 +351,7 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene return cmp; } - cmp = strcmp(mappingA.source, mappingB.source); + cmp = mappingA.source - mappingB.source; if (cmp !== 0) { return cmp; } @@ -366,7 +366,7 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene return cmp; } - return strcmp(mappingA.name, mappingB.name); + return mappingA.name - mappingB.name; } exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; @@ -375,14 +375,6 @@ function strcmp(aStr1, aStr2) { return 0; } - if (aStr1 === null) { - return 1; // aStr2 !== null - } - - if (aStr2 === null) { - return -1; // aStr1 !== null - } - if (aStr1 > aStr2) { return 1; } @@ -423,66 +415,3 @@ function compareByGeneratedPositionsInflated(mappingA, mappingB) { return strcmp(mappingA.name, mappingB.name); } exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; - -/** - * Strip any JSON XSSI avoidance prefix from the string (as documented - * in the source maps specification), and then parse the string as - * JSON. - */ -function parseSourceMapInput(str) { - return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, '')); -} -exports.parseSourceMapInput = parseSourceMapInput; - -/** - * Compute the URL of a source given the the source root, the source's - * URL, and the source map's URL. - */ -function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { - sourceURL = sourceURL || ''; - - if (sourceRoot) { - // This follows what Chrome does. - if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') { - sourceRoot += '/'; - } - // The spec says: - // Line 4: An optional source root, useful for relocating source - // files on a server or removing repeated values in the - // “sources” entry. This value is prepended to the individual - // entries in the “source” field. - sourceURL = sourceRoot + sourceURL; - } - - // Historically, SourceMapConsumer did not take the sourceMapURL as - // a parameter. This mode is still somewhat supported, which is why - // this code block is conditional. However, it's preferable to pass - // the source map URL to SourceMapConsumer, so that this function - // can implement the source URL resolution algorithm as outlined in - // the spec. This block is basically the equivalent of: - // new URL(sourceURL, sourceMapURL).toString() - // ... except it avoids using URL, which wasn't available in the - // older releases of node still supported by this library. - // - // The spec says: - // If the sources are not absolute URLs after prepending of the - // “sourceRoot”, the sources are resolved relative to the - // SourceMap (like resolving script src in a html document). - if (sourceMapURL) { - var parsed = urlParse(sourceMapURL); - if (!parsed) { - throw new Error("sourceMapURL could not be parsed"); - } - if (parsed.path) { - // Strip the last path component, but keep the "/". - var index = parsed.path.lastIndexOf('/'); - if (index >= 0) { - parsed.path = parsed.path.substring(0, index + 1); - } - } - sourceURL = join(urlGenerate(parsed), sourceURL); - } - - return normalize(sourceURL); -} -exports.computeSourceURL = computeSourceURL; |
