mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 1607559 - Part 2: Avoid perf issue with data: URLs for inlined source-maps. r=jlast
Depends on D69933 Differential Revision: https://phabricator.services.mozilla.com/D69934 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b8acb33b40
commit
d256d771ed
@ -25,21 +25,32 @@ function hasOriginalURL(url: string): boolean {
|
||||
}
|
||||
|
||||
function _resolveSourceMapURL(source: SourceMapInput) {
|
||||
const { url = "", sourceMapURL = "" } = source;
|
||||
let { url = "", sourceMapURL } = source;
|
||||
|
||||
if (!url) {
|
||||
// If the source doesn't have a URL, don't resolve anything.
|
||||
return { sourceMapURL, baseURL: sourceMapURL };
|
||||
}
|
||||
sourceMapURL = sourceMapURL || "";
|
||||
|
||||
const resolvedURL = new URL(sourceMapURL, url);
|
||||
const resolvedString = resolvedURL.toString();
|
||||
let resolvedString;
|
||||
let baseURL;
|
||||
|
||||
let baseURL = resolvedString;
|
||||
// When the sourceMap is a data: URL, fall back to using the
|
||||
// source's URL, if possible.
|
||||
if (resolvedURL.protocol == "data:") {
|
||||
// When the sourceMap is a data: URL, fall back to using the source's URL,
|
||||
// if possible. We don't use `new URL` here because it will be _very_ slow
|
||||
// for large inlined source-maps, and we don't actually need to parse them.
|
||||
if (sourceMapURL.startsWith("data:")) {
|
||||
resolvedString = sourceMapURL;
|
||||
baseURL = url;
|
||||
} else {
|
||||
resolvedString = new URL(
|
||||
sourceMapURL,
|
||||
// If the URL is a data: URL, the sourceMapURL needs to be absolute, so
|
||||
// we might as well pass `undefined` to avoid parsing a potentially
|
||||
// very large data: URL for no reason.
|
||||
url.startsWith("data:") ? undefined : url
|
||||
).toString();
|
||||
baseURL = resolvedString;
|
||||
}
|
||||
|
||||
return { sourceMapURL: resolvedString, baseURL };
|
||||
|
@ -3857,9 +3857,9 @@ function hasOriginalURL(url) {
|
||||
}
|
||||
|
||||
function _resolveSourceMapURL(source) {
|
||||
const {
|
||||
let {
|
||||
url = "",
|
||||
sourceMapURL = ""
|
||||
sourceMapURL
|
||||
} = source;
|
||||
|
||||
if (!url) {
|
||||
@ -3870,13 +3870,21 @@ function _resolveSourceMapURL(source) {
|
||||
};
|
||||
}
|
||||
|
||||
const resolvedURL = new URL(sourceMapURL, url);
|
||||
const resolvedString = resolvedURL.toString();
|
||||
let baseURL = resolvedString; // When the sourceMap is a data: URL, fall back to using the
|
||||
// source's URL, if possible.
|
||||
sourceMapURL = sourceMapURL || "";
|
||||
let resolvedString;
|
||||
let baseURL; // When the sourceMap is a data: URL, fall back to using the source's URL,
|
||||
// if possible. We don't use `new URL` here because it will be _very_ slow
|
||||
// for large inlined source-maps, and we don't actually need to parse them.
|
||||
|
||||
if (resolvedURL.protocol == "data:") {
|
||||
if (sourceMapURL.startsWith("data:")) {
|
||||
resolvedString = sourceMapURL;
|
||||
baseURL = url;
|
||||
} else {
|
||||
resolvedString = new URL(sourceMapURL, // If the URL is a data: URL, the sourceMapURL needs to be absolute, so
|
||||
// we might as well pass `undefined` to avoid parsing a potentially
|
||||
// very large data: URL for no reason.
|
||||
url.startsWith("data:") ? undefined : url).toString();
|
||||
baseURL = resolvedString;
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user