mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Enable the unicorn/prefer-string-replace-all
ESLint plugin rule
Note that the `replaceAll` method still requires that a *global* regular expression is used, however by using this method it's immediately obvious when looking at the code that all occurrences will be replaced; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#parameters Please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
This commit is contained in:
parent
5f64621d46
commit
1fc09f0235
26 changed files with 58 additions and 56 deletions
|
@ -103,8 +103,8 @@ describe("XML", function () {
|
|||
const buffer = [];
|
||||
root.dump(buffer);
|
||||
|
||||
expect(buffer.join("").replace(/\s+/g, "")).toEqual(
|
||||
xml.replace(/\s+/g, "")
|
||||
expect(buffer.join("").replaceAll(/\s+/g, "")).toEqual(
|
||||
xml.replaceAll(/\s+/g, "")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ WebServer.prototype = {
|
|||
}
|
||||
},
|
||||
_handler(req, res) {
|
||||
var url = req.url.replace(/\/\//g, "/");
|
||||
var url = req.url.replaceAll("//", "/");
|
||||
var urlParts = /([^?]*)((?:\?(.*))?)/.exec(url);
|
||||
try {
|
||||
// Guard against directory traversal attacks such as
|
||||
|
@ -89,7 +89,7 @@ WebServer.prototype = {
|
|||
// path.normalize returns a path on the basis of the current platform.
|
||||
// Windows paths cause issues in statFile and serverDirectoryIndex.
|
||||
// Converting to unix path would avoid platform checks in said functions.
|
||||
pathPart = pathPart.replace(/\\/g, "/");
|
||||
pathPart = pathPart.replaceAll("\\", "/");
|
||||
} catch (ex) {
|
||||
// If the URI cannot be decoded, a `URIError` is thrown. This happens for
|
||||
// malformed URIs such as `http://localhost:8888/%s%s` and should be
|
||||
|
@ -196,11 +196,11 @@ WebServer.prototype = {
|
|||
// Escape untrusted input so that it can safely be used in a HTML response
|
||||
// in HTML and in HTML attributes.
|
||||
return untrusted
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'");
|
||||
}
|
||||
|
||||
function serveDirectoryIndex(dir) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue