From 29adfe5ef789784c861b2cdeb15051ec2ba651a7 Mon Sep 17 00:00:00 2001 From: nlf Date: Wed, 7 Apr 2021 12:31:52 -0700 Subject: [PATCH 1/2] fix: backport regex fix from #76 PR-URL: https://github.com/npm/hosted-git-info/pull/84 Credit: @nlf Close: #84 Reviewed-by: @wraithgar --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 21e53fe..0885772 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ function fromUrl (giturl, opts) { isGitHubShorthand(giturl) ? 'github:' + giturl : giturl ) var parsed = parseGitUrl(url) - var shortcutMatch = url.match(new RegExp('^([^:]+):(?:(?:[^@:]+(?:[^@]+)?@)?([^/]*))[/](.+?)(?:[.]git)?($|#)')) + var shortcutMatch = url.match(/^([^:]+):(?:[^@]+@)?(?:([^/]*)\/)?([^#]+)/) var matches = Object.keys(gitHosts).map(function (gitHostName) { try { var gitHostInfo = gitHosts[gitHostName] @@ -55,7 +55,7 @@ function fromUrl (giturl, opts) { var defaultRepresentation = null if (shortcutMatch && shortcutMatch[1] === gitHostName) { user = shortcutMatch[2] && decodeURIComponent(shortcutMatch[2]) - project = decodeURIComponent(shortcutMatch[3]) + project = decodeURIComponent(shortcutMatch[3].replace(/\.git$/, '')) defaultRepresentation = 'shortcut' } else { if (parsed.host && parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return From 8d4b3697d79bcd89cdb36d1db165e3696c783a01 Mon Sep 17 00:00:00 2001 From: nlf Date: Wed, 7 Apr 2021 13:04:26 -0700 Subject: [PATCH 2/2] chore(release): 2.8.9 --- CHANGELOG.md | 10 ++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f86601..6987fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.8.9](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) (2021-04-07) + + +### Bug Fixes + +* backport regex fix from [#76](https://github.com/npm/hosted-git-info/issues/76) ([29adfe5](https://github.com/npm/hosted-git-info/commit/29adfe5)), closes [#84](https://github.com/npm/hosted-git-info/issues/84) + + + ## [2.8.8](https://github.com/npm/hosted-git-info/compare/v2.8.7...v2.8.8) (2020-02-29) diff --git a/package-lock.json b/package-lock.json index 4aba2c7..d0941ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hosted-git-info", - "version": "2.8.8", + "version": "2.8.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e47c096..8cc554c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hosted-git-info", - "version": "2.8.8", + "version": "2.8.9", "description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab", "main": "index.js", "repository": {