Skip to content

Commit 3d8c333

Browse files
Fix regex expression in env file (#19244)
* Fix regex expression * Fix tests * Fix reg exp * Fix test
1 parent c4d21f8 commit 3d8c333

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/client/common/variables/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function parseEnvLine(line: string): [string, string] {
114114
// https://github.com/motdotla/dotenv/blob/master/lib/main.js#L32
115115
// We don't use dotenv here because it loses ordering, which is
116116
// significant for substitution.
117-
const match = line.match(/^\s*([a-zA-Z]\w*)\s*=\s*(.*?)?\s*$/);
117+
const match = line.match(/^\s*(_*[a-zA-Z]\w*)\s*=\s*(.*?)?\s*$/);
118118
if (!match) {
119119
return ['', ''];
120120
}

src/test/common/variables/envVarsService.unit.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,23 +395,24 @@ Path=/usr/x:/usr/y
395395
SPAM=1234
396396
ham=5678
397397
Eggs=9012
398-
_bogus1=...
399398
1bogus2=...
400399
bogus 3=...
401400
bogus.4=...
402401
bogus-5=...
403402
bogus~6=...
404403
VAR1=3456
405404
VAR_2=7890
405+
_VAR_3=1234
406406
`);
407407

408408
expect(vars).to.not.equal(undefined, 'Variables is undefiend');
409-
expect(Object.keys(vars!)).lengthOf(5, 'Incorrect number of variables');
409+
expect(Object.keys(vars!)).lengthOf(6, 'Incorrect number of variables');
410410
expect(vars).to.have.property('SPAM', '1234', 'value is invalid');
411411
expect(vars).to.have.property('ham', '5678', 'value is invalid');
412412
expect(vars).to.have.property('Eggs', '9012', 'value is invalid');
413413
expect(vars).to.have.property('VAR1', '3456', 'value is invalid');
414414
expect(vars).to.have.property('VAR_2', '7890', 'value is invalid');
415+
expect(vars).to.have.property('_VAR_3', '1234', 'value is invalid');
415416
});
416417

417418
test('Empty values become empty string', () => {

0 commit comments

Comments
 (0)