Skip to content

Commit

Permalink
fix the case with escaped quote
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelien Guerre Chaley committed Jan 9, 2020
1 parent 33bf94a commit 8212d44
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions js/DotEnvParser.js
Expand Up @@ -13,8 +13,13 @@ class DotEnvParser {
}

static removeComments(str) {
if (str.includes('="') && str.endsWith('"')) {
return str;
if (str.includes('="')) {
if(str.endsWith('"')) {
return str;
} else {
const values = /(.*="(?:[^"\\]|\\.)*").*/.exec(str);
return values[1].replace('\\"','"');
}
} else {
return str.replace(/#.*/, '');
}
Expand Down
2 changes: 1 addition & 1 deletion test/envsub-global/envFile9.env
@@ -1 +1 @@
NOT_A_COMMENT="Daniel#not_a_comment"
NOT_A_COMMENT="Daniel#not_a_comment\"" #comment
4 changes: 2 additions & 2 deletions test/envsub-global/templateFileNotAComment_E
@@ -1,2 +1,2 @@
xxxDaniel#not_a_commentxxx xxxDaniel#not_a_commentxxx
xxxDaniel#not_a_commentxxx xxxDaniel#not_a_commentxxx
xxxDaniel#not_a_comment"xxx xxxDaniel#not_a_comment"xxx
xxxDaniel#not_a_comment"xxx xxxDaniel#not_a_comment"xxx

0 comments on commit 8212d44

Please sign in to comment.