Skip to content

Commit 33dad16

Browse files
committed
fix: backport regex fix from #76
1 parent afeaefd commit 33dad16

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function fromUrl (giturl, opts) {
4141
isGitHubShorthand(giturl) ? 'github:' + giturl : giturl
4242
)
4343
var parsed = parseGitUrl(url)
44-
var shortcutMatch = url.match(new RegExp('^([^:]+):(?:(?:[^@:]+(?:[^@]+)?@)?([^/]*))[/](.+?)(?:[.]git)?($|#)'))
44+
var shortcutMatch = url.match(/^([^:]+):(?:[^@]+@)?(?:([^/]*)\/)?([^#]+)/)
45+
// var shortcutMatch = url.match(new RegExp('^([^:]+):(?:(?:[^@:]+(?:[^@]+)?@)?([^/]*))[/](.+?)(?:[.]git)?($|#)'))
4546
var matches = Object.keys(gitHosts).map(function (gitHostName) {
4647
try {
4748
var gitHostInfo = gitHosts[gitHostName]
@@ -55,7 +56,7 @@ function fromUrl (giturl, opts) {
5556
var defaultRepresentation = null
5657
if (shortcutMatch && shortcutMatch[1] === gitHostName) {
5758
user = shortcutMatch[2] && decodeURIComponent(shortcutMatch[2])
58-
project = decodeURIComponent(shortcutMatch[3])
59+
project = decodeURIComponent(shortcutMatch[3].replace(/\.git$/, ''))
5960
defaultRepresentation = 'shortcut'
6061
} else {
6162
if (parsed.host && parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return

0 commit comments

Comments
 (0)