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

Merge pull request #16196 from Snuffleupagus/String-replaceAll

Use `String.prototype.replaceAll()` where appropriate
This commit is contained in:
Jonas Jenwald 2023-03-23 13:59:59 +01:00 committed by GitHub
commit 184f5701e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 72 additions and 70 deletions

View file

@ -117,7 +117,7 @@ function formatL10nValue(text, args) {
if (!args) {
return text;
}
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
return name in args ? args[name] : "{{" + name + "}}";
});
}

View file

@ -663,7 +663,7 @@ class PDFFindController {
#convertToRegExpString(query, hasDiacritics) {
const { matchDiacritics } = this._state;
let isUnicode = false;
query = query.replace(
query = query.replaceAll(
SPECIAL_CHARS_REG_EXP,
(
match,

View file

@ -352,7 +352,7 @@ class PDFLinkService {
if (params.has("search")) {
this.eventBus.dispatch("findfromurlhash", {
source: this,
query: params.get("search").replace(/"/g, ""),
query: params.get("search").replaceAll('"', ""),
phraseSearch: params.get("phrase") === "true",
});
}

View file

@ -211,7 +211,6 @@ function parseQueryString(query) {
return params;
}
const NullCharactersRegExp = /\x00/g;
const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
/**
@ -224,9 +223,9 @@ function removeNullCharacters(str, replaceInvisible = false) {
return str;
}
if (replaceInvisible) {
str = str.replace(InvisibleCharactersRegExp, " ");
str = str.replaceAll(InvisibleCharactersRegExp, " ");
}
return str.replace(NullCharactersRegExp, "");
return str.replaceAll("\x00", "");
}
/**