lib: refactor source_map to avoid unsafe array iteration

PR-URL: https://github.com/nodejs/node/pull/36734
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
This commit is contained in:
Antoine du Hamel committed 2021-01-13 15:50:53 +01:00
1 parent e70e793404
commit 3a44f37ef6
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -334,8 +334,8 @@ function cloneSourceMapV3(payload) {
* @return {number}
*/
function compareSourceMapEntry(entry1, entry2) {
const [lineNumber1, columnNumber1] = entry1;
const [lineNumber2, columnNumber2] = entry2;
const { 0: lineNumber1, 1: columnNumber1 } = entry1;
const { 0: lineNumber2, 1: columnNumber2 } = entry2;
if (lineNumber1 !== lineNumber2) {
return lineNumber1 - lineNumber2;
}
+1 -1
View File
@@ -138,7 +138,7 @@ function sourceMapFromFile(mapURL) {
// data:[<mediatype>][;base64],<data> see:
// https://tools.ietf.org/html/rfc2397#section-2
function sourceMapFromDataUrl(sourceURL, url) {
const [format, data] = StringPrototypeSplit(url, ',');
const { 0: format, 1: data } = StringPrototypeSplit(url, ',');
const splitFormat = StringPrototypeSplit(format, ';');
const contentType = splitFormat[0];
const base64 = splitFormat[splitFormat.length - 1] === 'base64';