From 8223f2a69bfb8cebd1f25904001afd41556684b7 Mon Sep 17 00:00:00 2001 From: CI Date: Wed, 27 Jul 2022 19:44:32 -0400 Subject: [PATCH] fix: support hyphens in git@ URLs (#50) --- lib/index.js | 2 +- test/index.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 988665c..d3a55bc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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.") diff --git a/test/index.js b/test/index.js index 98b0a38..43d66a5 100644 --- a/test/index.js +++ b/test/index.js @@ -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 => {