perf: use `.indexOf()` instead of `.split()`

This commit is contained in:
Nitin Kumar 2023-09-06 15:34:44 +05:30
parent e91b530fff
commit 95f4a3d747
2 changed files with 4 additions and 12 deletions

View File

@ -40,15 +40,9 @@ const sourceMappingURLRegex = RegExp(
* @returns {{replacementString: null|string, sourceMappingURL: null|string}} source mapping url
*/
function getSourceMappingURL(code) {
const lines = code.split(/^/m);
let match;
for (let i = lines.length - 1; i >= 0; i--) {
match = lines[i].match(sourceMappingURLRegex);
if (match) {
break;
}
}
const lastLineIndex = code.indexOf("\n");
const lastLine = code.substring(lastLineIndex + 1);
const match = lastLine.match(sourceMappingURLRegex);
const sourceMappingURL = match ? match[1] || match[2] || "" : null;

View File

@ -1,3 +1 @@
module.exports = [
/Failed to parse source map/
];
module.exports = [/Failed to parse source map/];