ssh-config 4.4.3 → 4.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-config",
3
3
  "description": "SSH config parser and stringifier",
4
- "version": "4.4.3",
4
+ "version": "4.4.4",
5
5
  "author": "Chen Yangjian (https://www.cyj.me)",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "mocha": "^8.2.1",
25
25
  "nyc": "^15.1.0",
26
26
  "sinon": "^17.0.1",
27
- "typescript": "^4.6.3"
27
+ "typescript": "^5.4.4"
28
28
  },
29
29
  "scripts": {
30
30
  "lint": "eslint --ext ts .",
package/src/ssh-config.js CHANGED
@@ -17,7 +17,7 @@ var LineType;
17
17
  (function (LineType) {
18
18
  LineType[LineType["DIRECTIVE"] = 1] = "DIRECTIVE";
19
19
  LineType[LineType["COMMENT"] = 2] = "COMMENT";
20
- })(LineType = exports.LineType || (exports.LineType = {}));
20
+ })(LineType || (exports.LineType = LineType = {}));
21
21
  const MULTIPLE_VALUE_PROPS = [
22
22
  'IdentityFile',
23
23
  'LocalForward',
@@ -148,11 +148,11 @@ class SSHConfig extends Array {
148
148
  }
149
149
  }
150
150
  }
151
- if (canonicalDomains.length > 0 && canonicalizeHostName) {
151
+ if (canonicalDomains.length > 0 && canonicalizeHostName && context.params.Host === context.params.OriginalHost) {
152
152
  for (const domain of canonicalDomains) {
153
- const host = `${line.value}.${domain}`;
154
- const { stdout } = (0, child_process_1.spawnSync)('nslookup', [host]);
155
- if (!/server can't find/.test(stdout.toString())) {
153
+ const host = `${context.params.OriginalHost}.${domain}`;
154
+ const { status, stderr } = (0, child_process_1.spawnSync)('nslookup', [host]);
155
+ if (status === 0 && !/can't find/.test(stderr.toString())) {
156
156
  context.params.Host = host;
157
157
  setProperty('Host', host);
158
158
  doPass();
@@ -302,9 +302,9 @@ class SSHConfig extends Array {
302
302
  return config;
303
303
  }
304
304
  }
305
- exports.default = SSHConfig;
306
305
  SSHConfig.DIRECTIVE = LineType.DIRECTIVE;
307
306
  SSHConfig.COMMENT = LineType.COMMENT;
307
+ exports.default = SSHConfig;
308
308
  /**
309
309
  * Parse SSH config text into structured object.
310
310
  */
@@ -416,7 +416,7 @@ function parse(text) {
416
416
  }
417
417
  // otherwise ignore the space
418
418
  }
419
- else if (chr === '#') {
419
+ else if (chr === '#' && results.length > 0) {
420
420
  break;
421
421
  }
422
422
  else {