refactor: use replaceAll() instead of replace() when appropriate (#39721)

refactor: use replaceAll() instead of replace() when appropriate
This commit is contained in:
Milan Burda 2023-09-07 08:50:14 +02:00 committed by GitHub
parent 029127a8b6
commit f6e8544ef6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 20 deletions

View file

@ -33,7 +33,7 @@ const normalizeAccessKey = (text: string) => {
// macOS does not have access keys so remove single ampersands
// and replace double ampersands with a single ampersand
if (process.platform === 'darwin') {
return text.replace(/&(&?)/g, '$1');
return text.replaceAll(/&(&?)/g, '$1');
}
// Linux uses a single underscore as an access key prefix so escape
@ -41,7 +41,7 @@ const normalizeAccessKey = (text: string) => {
// ampersands with a single ampersand, and replace a single ampersand with
// a single underscore
if (process.platform === 'linux') {
return text.replace(/_/g, '__').replace(/&(.?)/g, (match, after) => {
return text.replaceAll('_', '__').replaceAll(/&(.?)/g, (match, after) => {
if (after === '&') return after;
return `_${after}`;
});