mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-23 04:25:24 +00:00
Remove environment variable whitespace trimming
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
3b43579da7
commit
6bf008cc85
@ -4,7 +4,7 @@ import { EnvVarObject } from './types';
|
||||
|
||||
export function envArrayToObject(env: string[]): EnvVarObject {
|
||||
const toPair = (keyVal: string) => {
|
||||
const m = keyVal.match(/^([^=]+)=\s*(.*)\s*$/);
|
||||
const m = keyVal.match(/^([^=]+)=(.*)$/);
|
||||
if (m == null) {
|
||||
console.log(
|
||||
`WARNING: Could not correctly parse env var ${keyVal}. ` +
|
||||
|
@ -37,13 +37,15 @@ describe 'conversions', ->
|
||||
expect(conversion.envArrayToObject([])).to.deep.equal({})
|
||||
expect(conversion.envArrayToObject(1)).to.deep.equal({})
|
||||
|
||||
it 'should ignore leading and trailing whitespace', ->
|
||||
expect(conversion.envArrayToObject([
|
||||
'TEST=\ntest'
|
||||
'TEST2=test\n'
|
||||
'TEST3=\ntest\n'
|
||||
])).to.deep.equal({
|
||||
TEST: 'test'
|
||||
TEST2: 'test'
|
||||
TEST3: 'test'
|
||||
})
|
||||
it 'should correctly handle whitespace', ->
|
||||
expect(conversion.envArrayToObject([
|
||||
'key1= test',
|
||||
'key2=test\ntest',
|
||||
'key3=test ',
|
||||
'key4= test '
|
||||
])).to.deep.equal({
|
||||
key1: ' test',
|
||||
key2: 'test\ntest',
|
||||
key3: 'test ',
|
||||
key4: ' test ',
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user