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:
commit
184f5701e9
30 changed files with 72 additions and 70 deletions
|
@ -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 + "}}";
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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", "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue