mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
refactor: use replaceAll() instead of replace() when appropriate (#39721)
refactor: use replaceAll() instead of replace() when appropriate
This commit is contained in:
@@ -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}`;
|
||||
});
|
||||
|
||||
@@ -63,8 +63,8 @@ if (process.platform === 'win32') {
|
||||
|
||||
if (fs.existsSync(updateDotExe)) {
|
||||
const packageDir = path.dirname(path.resolve(updateDotExe));
|
||||
const packageName = path.basename(packageDir).replace(/\s/g, '');
|
||||
const exeName = path.basename(process.execPath).replace(/\.exe$/i, '').replace(/\s/g, '');
|
||||
const packageName = path.basename(packageDir).replaceAll(/\s/g, '');
|
||||
const exeName = path.basename(process.execPath).replace(/\.exe$/i, '').replaceAll(/\s/g, '');
|
||||
|
||||
app.setAppUserModelId(`com.squirrel.${packageName}.${exeName}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user