Permalink
Browse files

connection: use same regexp for both CWD and PWD parsing

  • Loading branch information...
1 parent be59ed8 commit 23530487e2be811dacead92bc8cc8b030e519ef1 @mscdex committed Dec 19, 2013
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/connection.js
View
@@ -12,8 +12,7 @@ var XRegExp = require('xregexp').XRegExp;
var REX_TIMEVAL = XRegExp.cache('^(?<year>\\d{4})(?<month>\\d{2})(?<date>\\d{2})(?<hour>\\d{2})(?<minute>\\d{2})(?<second>\\d+)(?:.\\d+)?$'),
RE_PASV = /([\d]+),([\d]+),([\d]+),([\d]+),([-\d]+),([-\d]+)/,
RE_EOL = /\r?\n/g,
- RE_CWD = /"(.+)"(?: |$)/,
- RE_PWD = /^"(.+)"(?: |$)/,
+ RE_WD = /"(.+)"(?: |$)/,
RE_SYST = /^([^ ]+)(?: |$)/;
var /*TYPE = {
@@ -344,7 +343,7 @@ FTP.prototype.cwd = function(path, cb, promote) {
this._send('CWD ' + path, function(err, text, code) {
if (err)
return cb(err);
- var m = RE_CWD.exec(text);
+ var m = RE_WD.exec(text);
cb(undefined, m ? m[1] : undefined);
}, promote);
};
@@ -639,7 +638,7 @@ FTP.prototype.pwd = function(cb) { // PWD is optional
}, true);
} else if (err)
return cb(err);
- cb(undefined, RE_PWD.exec(text)[1]);
+ cb(undefined, RE_WD.exec(text)[1]);
});
};

0 comments on commit 2353048

Please sign in to comment.