Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

add support for @ signs in usernames. Doesn't seem to break anything #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
9 changes: 9 additions & 0 deletions test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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%[email protected]: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() {
Expand Down