Skip to content

Commit

Permalink
When forming the URL to retrieve a source map, if it is already an ab…
Browse files Browse the repository at this point in the history
…solute URL then use it as is (emberjs#908) (emberjs#909)
  • Loading branch information
fusion2004 authored and cyril-sf committed Mar 30, 2022
1 parent c273b8e commit 318e9ef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ember_debug/libs/source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ function retrieveSourceMap(source) {
}

function relativeToAbsolute(file, url) {
if (!file) { return url; }
// Regex from https://stackoverflow.com/a/19709846
// This will match the most common prefixes we care about: "http://", "https://", "//"
let absoluteUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');

// If we don't have a file URL or the sourcemap URL is absolute, then return the sourcemap URL.
if (!file || absoluteUrlRegex.test(url)) { return url; }

// Otherwise, find the sourcemap URL relative to the original file.
let dir = file.split('/');
dir.pop();
dir.push(url);
Expand Down

0 comments on commit 318e9ef

Please sign in to comment.