Skip to content

Commit 5a5e0d6

Browse files
committed
lib: fix source map url parse in dynamic imports
1 parent 488a854 commit 5a5e0d6

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

lib/internal/source_map/source_map_cache.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ function dataFromUrl(sourceURL, sourceMappingURL) {
247247
}
248248
}
249249

250-
const mapURL = new URL(sourceMappingURL, sourceURL).href;
250+
const mapURL = URLParse(sourceMappingURL, sourceURL);
251+
if (mapURL === null) {
252+
return null;
253+
}
251254
return sourceMapFromFile(mapURL);
252255
}
253256

@@ -276,7 +279,7 @@ function lineLengths(content) {
276279

277280
/**
278281
* Read source map from file.
279-
* @param {string} mapURL - file url of the source map
282+
* @param {URL} mapURL - file url of the source map
280283
* @returns {object} deserialized source map JSON object
281284
*/
282285
function sourceMapFromFile(mapURL) {

test/parallel/test-source-map-invalid-url.js

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)