Skip to content

Commit

Permalink
fix: support hyphens in git@ URLs (IonicaBizau#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
CI committed Jul 27, 2022
1 parent 155b10a commit 8223f2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -37,7 +37,7 @@ import normalizeUrl from "normalize-url";
const parseUrl = (url, normalize = false) => {

// Constants
const GIT_RE = /((git@|http(s)?:\/\/)([\w\.@]+)(\/|:))(([\~,\w,\-,\_,\/]+)(.git){0,1}((\/){0,1}))/
const GIT_RE = /((git@|http(s)?:\/\/)([\w\.\-@]+)(\/|:))(([\~,\w,\-,\_,\/]+)(.git){0,1}((\/){0,1}))/

if (typeof url !== "string" || !url.trim()) {
const err = new Error("Invalid url.")
Expand Down
15 changes: 15 additions & 0 deletions test/index.js
Expand Up @@ -88,6 +88,21 @@ const INPUTS = [
, query: {}
}
]
, [
["git@github.my-enterprise.com:my-org/my-repo.git", false],
{
protocols: [ 'ssh' ]
, protocol: 'ssh'
, port: ''
, resource: 'github.my-enterprise.com'
, user: 'git'
, password: ''
, pathname: '/my-org/my-repo.git'
, hash: ''
, search: ''
, query: {}
}
]
];

tester.describe("check urls", test => {
Expand Down

0 comments on commit 8223f2a

Please sign in to comment.