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

@ -284,7 +284,7 @@ describe('web security', () => {
describe('accessing file://', () => {
async function loadFile (w: BrowserWindow) {
const thisFile = url.format({
pathname: __filename.replace(/\\/g, '/'),
pathname: __filename.replaceAll('\\', '/'),
protocol: 'file',
slashes: true
});
@ -461,7 +461,7 @@ describe('command line switches', () => {
throw new Error(`Process exited with code "${code}" signal "${signal}" output "${output}" stderr "${stderr}"`);
}
output = output.replace(/(\r\n|\n|\r)/gm, '');
output = output.replaceAll(/(\r\n|\n|\r)/gm, '');
expect(output).to.equal(result);
};
@ -1050,7 +1050,7 @@ describe('chromium features', () => {
it('defines a window.location getter', async () => {
let targetURL: string;
if (process.platform === 'win32') {
targetURL = `file:///${fixturesPath.replace(/\\/g, '/')}/pages/base-page.html`;
targetURL = `file:///${fixturesPath.replaceAll('\\', '/')}/pages/base-page.html`;
} else {
targetURL = `file://${fixturesPath}/pages/base-page.html`;
}
@ -1977,7 +1977,7 @@ describe('chromium features', () => {
ifdescribe(features.isPDFViewerEnabled())('PDF Viewer', () => {
const pdfSource = url.format({
pathname: path.join(__dirname, 'fixtures', 'cat.pdf').replace(/\\/g, '/'),
pathname: path.join(__dirname, 'fixtures', 'cat.pdf').replaceAll('\\', '/'),
protocol: 'file',
slashes: true
});