Skip to content

Commit

Permalink
Fix unix address parser (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro authored and sindresorhus committed Jun 27, 2017
1 parent f535947 commit c0c6bcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function normalizeArguments(url, opts) {
}

if (opts.hostname === 'unix') {
const matches = /(.+):(.+)/.exec(opts.path);
const matches = /(.+?):(.+)/.exec(opts.path);

if (matches) {
opts.socketPath = matches[1];
Expand Down
9 changes: 9 additions & 0 deletions test/unix-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ test.before('setup', async () => {
res.end('ok');
});

s.on('/foo:bar', (req, res) => {
res.end('ok');
});

await s.listen(socketPath);
});

Expand All @@ -28,6 +32,11 @@ test('protocol-less works', async t => {
t.is((await got(url)).body, 'ok');
});

test('address with : works', async t => {
const url = format('unix:%s:%s', socketPath, '/foo:bar');
t.is((await got(url)).body, 'ok');
});

test.after('cleanup', async () => {
await s.close();
});

0 comments on commit c0c6bcf

Please sign in to comment.