diff --git a/lib/client.js b/lib/client.js index f73981d..2a6f4fe 100644 --- a/lib/client.js +++ b/lib/client.js @@ -25,7 +25,7 @@ Client.prototype.defaults = function(options) { Client.prototype.parse = function(remote) { if (_.isString(remote)) { // username[:password]@host[:port][:/path/to] - var regex = /^([a-zA-Z0-9\-\._]+)(?:\:(.*))?@([^:]+)(?:\:([0-9]+))?(?:\:(.*))?$/; + var regex = /^([a-zA-Z0-9\-\._@]+)(?:\:(.*))?@([^:]+)(?:\:([0-9]+))?(?:\:(.*))?$/; var m = remote.match(regex); if (!m) return {}; var ret = { diff --git a/test/client.test.js b/test/client.test.js index 1230d70..2ada0de 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -121,6 +121,15 @@ describe('Client', function() { expect(ret.path).to.equal('/home/admin/path'); }); + it('can handle "@" in username', function() { + ret = client.parse('admin@2:bx%9@example.com:12345:/home/admin/path'); + expect(ret.username).to.equal('admin@2'); + expect(ret.password).to.equal('bx%9'); + expect(ret.host).to.equal('example.com'); + expect(ret.port).to.equal('12345'); + expect(ret.path).to.equal('/home/admin/path'); + }); + }); describe('when calling from windows', function() {