1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Enable the ESLint no-useless-escape rule (PR 12551 follow-up)

Note that a number of these cases are covered by existing unit-tests, and a few others only matter for the development/build scripts.
Furthermore, I've also tried to the best of my ability to test each case *manually* to hopefully further reduce the likelihood of this patch introducing any bugs.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-useless-escape
This commit is contained in:
Jonas Jenwald 2020-11-07 12:59:53 +01:00
parent e3851a6765
commit 9602844368
9 changed files with 11 additions and 10 deletions

View file

@ -1552,7 +1552,7 @@ const PDFViewerApplication = {
if (!producer.includes(generator)) {
return false;
}
generatorId = generator.replace(/[ .\-]/g, "_");
generatorId = generator.replace(/[ .-]/g, "_");
return true;
});
}

View file

@ -115,7 +115,7 @@ var FontInspector = (function FontInspectorClosure() {
name.textContent = fontName;
var download = document.createElement("a");
if (url) {
url = /url\(['"]?([^\)"']+)/.exec(url);
url = /url\(['"]?([^)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
download.href = URL.createObjectURL(

View file

@ -617,10 +617,10 @@ function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
);
return defaultFilename;
}
const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
// SCHEME HOST 1.PATH 2.QUERY 3.REF
const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
// SCHEME HOST 1.PATH 2.QUERY 3.REF
// Pattern to get last matching NAME.pdf
const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
const splitURI = reURI.exec(url);
let suggestedFilename =
reFilename.exec(splitURI[1]) ||