ssh-config 5.0.1 → 5.0.3
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/package.json +1 -1
- package/src/ssh-config.js +17 -4
package/package.json
CHANGED
package/src/ssh-config.js
CHANGED
|
@@ -20,7 +20,7 @@ var LineType;
|
|
|
20
20
|
LineType[LineType["DIRECTIVE"] = 1] = "DIRECTIVE";
|
|
21
21
|
LineType[LineType["COMMENT"] = 2] = "COMMENT";
|
|
22
22
|
})(LineType || (exports.LineType = LineType = {}));
|
|
23
|
-
const
|
|
23
|
+
const REPEATABLE_DIRECTIVES = [
|
|
24
24
|
'IdentityFile',
|
|
25
25
|
'LocalForward',
|
|
26
26
|
'RemoteForward',
|
|
@@ -115,9 +115,22 @@ class SSHConfig extends Array {
|
|
|
115
115
|
};
|
|
116
116
|
const obj = {};
|
|
117
117
|
const setProperty = (name, value) => {
|
|
118
|
-
|
|
118
|
+
let val;
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
if (/ProxyCommand/i.test(name)) {
|
|
121
|
+
val = value.map(({ val, separator, quoted }) => {
|
|
122
|
+
return `${separator}${quoted ? `"${val.replace(/"/g, '\\"')}"` : val}`;
|
|
123
|
+
}).join('').trim();
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
val = value.map(({ val }) => val);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
val = value;
|
|
131
|
+
}
|
|
119
132
|
const val0 = Array.isArray(val) ? val[0] : val;
|
|
120
|
-
if (
|
|
133
|
+
if (REPEATABLE_DIRECTIVES.includes(name)) {
|
|
121
134
|
const list = (obj[name] || (obj[name] = []));
|
|
122
135
|
list.push(...[].concat(val));
|
|
123
136
|
}
|
|
@@ -544,7 +557,7 @@ function stringify(config) {
|
|
|
544
557
|
if (line.type === LineType.COMMENT) {
|
|
545
558
|
str += line.content;
|
|
546
559
|
}
|
|
547
|
-
else if (line.type === LineType.DIRECTIVE &&
|
|
560
|
+
else if (line.type === LineType.DIRECTIVE && REPEATABLE_DIRECTIVES.includes(line.param)) {
|
|
548
561
|
(Array.isArray(line.value) ? line.value : [line.value]).forEach((value, i, values) => {
|
|
549
562
|
str += formatDirective({ ...line, value: typeof value !== 'string' ? value.val : value });
|
|
550
563
|
if (i < values.length - 1)
|