fix: make feature strings more robust to whitespace (#15602)
Fixes #15594
This commit is contained in:
parent
c52cf01a3c
commit
10969b8c3c
2 changed files with 26 additions and 3 deletions
23
spec/internal-spec.js
Normal file
23
spec/internal-spec.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const chai = require('chai')
|
||||
const { expect } = chai
|
||||
|
||||
describe('feature-string parsing', () => {
|
||||
it('is indifferent to whitespace around keys and values', () => {
|
||||
const parseFeaturesString = require('@electron/internal/common/parse-features-string')
|
||||
const checkParse = (string, parsed) => {
|
||||
const features = {}
|
||||
parseFeaturesString(string, (k, v) => { features[k] = v })
|
||||
expect(features).to.deep.equal(parsed)
|
||||
}
|
||||
checkParse('a=yes,c=d', { a: true, c: 'd' })
|
||||
checkParse('a=yes ,c=d', { a: true, c: 'd' })
|
||||
checkParse('a=yes, c=d', { a: true, c: 'd' })
|
||||
checkParse('a=yes , c=d', { a: true, c: 'd' })
|
||||
checkParse(' a=yes , c=d', { a: true, c: 'd' })
|
||||
checkParse(' a= yes , c=d', { a: true, c: 'd' })
|
||||
checkParse(' a = yes , c=d', { a: true, c: 'd' })
|
||||
checkParse(' a = yes , c =d', { a: true, c: 'd' })
|
||||
checkParse(' a = yes , c = d', { a: true, c: 'd' })
|
||||
checkParse(' a = yes , c = d ', { a: true, c: 'd' })
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue