maiass 5.9.37 → 5.9.39
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/lib/config-manager.js +12 -6
- package/package.json +1 -1
package/lib/config-manager.js
CHANGED
|
@@ -55,10 +55,16 @@ export function readConfig(configPath) {
|
|
|
55
55
|
if (key && valueParts.length > 0) {
|
|
56
56
|
let value = valueParts.join('=').trim();
|
|
57
57
|
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
// Strip surrounding quotes, following dotenv conventions:
|
|
59
|
+
// - Double-quoted: unescape \\ → \ and \" → " after stripping (standard escape sequences)
|
|
60
|
+
// - Single-quoted: strip only, no unescaping (everything is literal)
|
|
61
|
+
// - Unquoted: use as-is (important for Windows paths like C:\Users\name)
|
|
62
|
+
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
63
|
+
value = value.slice(1, -1)
|
|
64
|
+
.replace(/\\"/g, '"') // unescape \" → "
|
|
65
|
+
.replace(/\\\\/g, '\\'); // unescape \\ → \
|
|
66
|
+
} else if (value.length >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
|
67
|
+
value = value.slice(1, -1); // single-quoted: literal, no unescaping
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
config[key.trim()] = value;
|
|
@@ -132,9 +138,9 @@ export function writeConfig(configPath, config, options = {}) {
|
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
// Quote values that contain spaces or special characters.
|
|
135
|
-
//
|
|
141
|
+
// Escape backslashes first, then double-quotes, for .env file format.
|
|
136
142
|
const needsQuotes = /[\s#"'\\]/.test(value);
|
|
137
|
-
const quotedValue = needsQuotes ? `"${value.replace(/"/g, '\\"')}"` : value;
|
|
143
|
+
const quotedValue = needsQuotes ? `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"` : value;
|
|
138
144
|
|
|
139
145
|
lines.push(`${key}=${quotedValue}`);
|
|
140
146
|
});
|