@dotenvx/dotenvx 0.43.0 → 0.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,7 +32,7 @@ brew install dotenvx/brew/dotenvx
32
32
  ```
33
33
  > * [other global ways to install](https://dotenvx.com/docs/install)
34
34
  >
35
- > Intall globally as a cli to unlock dotenv for ANY language, framework, or platform. 💥
35
+ > Install globally as a cli to unlock dotenv for ANY language, framework, or platform. 💥
36
36
  >
37
37
  > I am using (and recommending) this approach going forward. – [motdotla](https://github.com/motdotla)
38
38
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.43.0",
2
+ "version": "0.43.1",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -6,8 +6,19 @@ function replace (src, key, value) {
6
6
 
7
7
  const parsed = dotenv.parse(src)
8
8
  if (Object.prototype.hasOwnProperty.call(parsed, key)) {
9
- // replace
10
- const regex = new RegExp(`^${key}=(?:(["'\`])[^\\1]*\\1|[^\\n]*)(\\n[^A-Z0-9_].*)*`, 'm')
9
+ const regex = new RegExp(
10
+ `^${key}=` + // start of line with key
11
+ '(?:' + // begin non-capturing group for handling both quoted and unquoted values
12
+ '(["\'`])' + // capture opening quote (' or " or `)
13
+ '[^\\1]*' + // match any character except the quote captured initially
14
+ '\\1' + // match the same closing quote as captured at the start
15
+ '|' + // OR
16
+ '[^#\\n]*' + // match any characters until a # (comment) or newline
17
+ ')' + // end non-capturing group
18
+ '(\\n[^A-Z0-9_].*)*', // match subsequent lines that don't start with a letter, number, or underscore (continuation lines)
19
+ 'm' // apply multiline mode, so ^ and $ match start and end of lines, not just the whole string
20
+ )
21
+
11
22
  output = src.replace(regex, formatted)
12
23
  } else {
13
24
  // append