ssh-config 5.0.1 → 5.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ssh-config.js +15 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-config",
3
3
  "description": "SSH config parser and stringifier",
4
- "version": "5.0.1",
4
+ "version": "5.0.2",
5
5
  "author": "Chen Yangjian (https://www.cyj.me)",
6
6
  "repository": {
7
7
  "type": "git",
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 MULTIPLE_VALUE_PROPS = [
23
+ const REPEATABLE_DIRECTIVES = [
24
24
  'IdentityFile',
25
25
  'LocalForward',
26
26
  'RemoteForward',
@@ -115,9 +115,20 @@ class SSHConfig extends Array {
115
115
  };
116
116
  const obj = {};
117
117
  const setProperty = (name, value) => {
118
- const val = Array.isArray(value) ? value.map(({ val }) => val) : value;
118
+ let val;
119
+ if (Array.isArray(value)) {
120
+ if (/ProxyCommand/i.test(name)) {
121
+ val = value.map(({ val, separator }) => `${separator}${val}`).join('').trim();
122
+ }
123
+ else {
124
+ val = value.map(({ val }) => val);
125
+ }
126
+ }
127
+ else {
128
+ val = value;
129
+ }
119
130
  const val0 = Array.isArray(val) ? val[0] : val;
120
- if (MULTIPLE_VALUE_PROPS.includes(name)) {
131
+ if (REPEATABLE_DIRECTIVES.includes(name)) {
121
132
  const list = (obj[name] || (obj[name] = []));
122
133
  list.push(...[].concat(val));
123
134
  }
@@ -544,7 +555,7 @@ function stringify(config) {
544
555
  if (line.type === LineType.COMMENT) {
545
556
  str += line.content;
546
557
  }
547
- else if (line.type === LineType.DIRECTIVE && MULTIPLE_VALUE_PROPS.includes(line.param)) {
558
+ else if (line.type === LineType.DIRECTIVE && REPEATABLE_DIRECTIVES.includes(line.param)) {
548
559
  (Array.isArray(line.value) ? line.value : [line.value]).forEach((value, i, values) => {
549
560
  str += formatDirective({ ...line, value: typeof value !== 'string' ? value.val : value });
550
561
  if (i < values.length - 1)