File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,8 +13,16 @@ class DotEnvParser {
1313 }
1414
1515 static removeComments ( str ) {
16- if ( str . includes ( '="' ) && str . endsWith ( '"' ) ) {
17- return str ;
16+ if ( str . includes ( '="' ) ) {
17+ if ( str . endsWith ( '"' ) ) {
18+ return str ;
19+ } else {
20+ const values = / ( .* = " (?: [ ^ " \\ ] | \\ .) * " ) ( .* ) / . exec ( str ) ;
21+ if ( ! values [ 2 ] . trim ( ) . startsWith ( '#' ) ) {
22+ throw new Error ( `incorrect line ${ str } ` )
23+ }
24+ return values [ 1 ] . replace ( '\\"' , '"' ) ;
25+ }
1826 } else {
1927 return str . replace ( / # .* / , '' ) ;
2028 }
Original file line number Diff line number Diff line change 1- NOT_A_COMMENT = " Daniel#not_a_comment"
1+ NOT_A_COMMENT = " Daniel#not_a_comment\" " # comment
Original file line number Diff line number Diff line change 1- xxxDaniel#not_a_commentxxx xxxDaniel#not_a_commentxxx
2- xxxDaniel#not_a_commentxxx xxxDaniel#not_a_commentxxx
1+ xxxDaniel#not_a_comment"xxx xxxDaniel#not_a_comment"xxx
2+ xxxDaniel#not_a_comment"xxx xxxDaniel#not_a_comment"xxx
You can’t perform that action at this time.
0 commit comments