Skip to content

Commit 56ab152

Browse files
committed
use regex to replace unicode quotes in electron switches
1 parent c712e76 commit 56ab152

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

packages/server/lib/append_electron_switches.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ export const appendElectronSwitches = (app: Electron.App) => {
3636
// thus we don't have to worry about casting
3737
// --foo=false for example will be "--foo", "false"
3838
if (value.length) {
39-
let joinedValues = value.join('=')
40-
4139
// check if the arg is wrapped in " or ' (unicode)
42-
const isWrappedInQuotes = !!['\u0022', '\u0027'].find(((charAsUnicode) => joinedValues.startsWith(charAsUnicode) && joinedValues.endsWith(charAsUnicode)))
43-
44-
if (isWrappedInQuotes) {
45-
joinedValues = joinedValues.slice(1, -1)
46-
}
40+
const joinedValues = value.join('=').replace(/^(?:['"](.*)['"]|\u0022(.*)\u0027)$/, '$1$2')
4741

4842
app.commandLine.appendSwitch(key, joinedValues)
4943
} else {

packages/server/test/unit/append_electron_switches_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('lib/append_electron_switches', () => {
9898
commandLine: {
9999
appendSwitch: sinon.stub(),
100100
},
101-
} as Electron.App
101+
} as unknown as Electron.App
102102

103103
appendElectronSwitches(mockApp)
104104

@@ -118,7 +118,7 @@ describe('lib/append_electron_switches', () => {
118118
commandLine: {
119119
appendSwitch: sinon.stub(),
120120
},
121-
} as Electron.App
121+
} as unknown as Electron.App
122122

123123
appendElectronSwitches(mockApp)
124124
expect(mockApp.commandLine.appendSwitch).to.have.been.calledWith('--foo')

0 commit comments

Comments
 (0)