Skip to content

Commit 29adfe5

Browse files
committed
fix: backport regex fix from #76
PR-URL: #84 Credit: @nlf Close: #84 Reviewed-by: @wraithgar
1 parent afeaefd commit 29adfe5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ 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(/^([^:]+):(?:[^@]+@)?(?:([^/]*)\/)?([^#]+)/)
4545
var matches = Object.keys(gitHosts).map(function (gitHostName) {
4646
try {
4747
var gitHostInfo = gitHosts[gitHostName]
@@ -55,7 +55,7 @@ function fromUrl (giturl, opts) {
5555
var defaultRepresentation = null
5656
if (shortcutMatch && shortcutMatch[1] === gitHostName) {
5757
user = shortcutMatch[2] && decodeURIComponent(shortcutMatch[2])
58-
project = decodeURIComponent(shortcutMatch[3])
58+
project = decodeURIComponent(shortcutMatch[3].replace(/\.git$/, ''))
5959
defaultRepresentation = 'shortcut'
6060
} else {
6161
if (parsed.host && parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy