Skip to content

Commit 55cc550

Browse files
committed
fix(parser): strip trailing spaces from key/value pair
1 parent 965e750 commit 55cc550

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class Parser {
9494
throw new Error('Could not parse key value pair from line "' + line + '"');
9595
}
9696

97-
let key = pair[0];
97+
let key = pair[0].trim();
9898
let value = this.stripComments(pair[1]);
9999

100100
return {

test/unit/parser.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ describe('the parser', () => {
3838
expect(sut.getEnv()).toEqual(expected);
3939
});
4040

41+
it('should strip spaces from vars and values', () => {
42+
sut.doParse(`TEST1 = VALUE\nTEST2= VALUE\nTEST3 =VALUE\nTEST4=VALUE\n TEST5 = VALUE\nTEST6 = VALUE`);
43+
44+
let expected = {
45+
TEST1: 'VALUE',
46+
TEST2: 'VALUE',
47+
TEST3: 'VALUE',
48+
TEST4: 'VALUE',
49+
TEST5: 'VALUE',
50+
TEST6: 'VALUE'
51+
};
52+
53+
expect(sut.getEnv()).toEqual(expected);
54+
});
55+
4156
it('should ignore comments', () => {
4257
sut.doParse(`#ENV1=value3\n#ENV2=value2\nENV3=value1`);
4358

0 commit comments

Comments
 (0)