Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions lib/parse-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const correctProtocol = (arg, protocols) => {
return arg
}

const doubleSlash = arg.indexOf('//')
if (doubleSlash === firstColon + 1) {
return arg
}

const firstAt = arg.indexOf('@')
if (firstAt > -1) {
if (firstAt > firstColon) {
Expand All @@ -30,11 +35,6 @@ const correctProtocol = (arg, protocols) => {
}
}

const doubleSlash = arg.indexOf('//')
if (doubleSlash === firstColon + 1) {
return arg
}

return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`
}

Expand Down
7 changes: 7 additions & 0 deletions test/parse-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ t.test('can parse file urls', async t => {
t.ok(parseUrl(u))
t.ok(HostedGit.parseUrl(u))
})

t.test('can parse custom urls', async t => {
const u = 'foobar://user:host@path'
t.ok(parseUrl(u, {}))
t.equal(parseUrl(u, {}).protocol, 'foobar:')
t.ok(HostedGit.parseUrl(u))
})