From bdd9745b6c3c9f48b40babe73b282675219f352f Mon Sep 17 00:00:00 2001 From: Gal Halup Date: Sun, 31 Jul 2022 17:41:42 +0300 Subject: [PATCH] fix: support dot in git@ URLS --- lib/index.js | 2 +- test/index.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 988665c..149f1b4 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..0b154df 100644 --- a/test/index.js +++ b/test/index.js @@ -88,6 +88,20 @@ const INPUTS = [ , query: {} } ] + , [ + ["git@github.com:halup/Cloud.API.Gateway.git", false] + , { + protocols: [ "ssh" ] + , protocol: "ssh" + , port: "" + , resource: "github.com" + , user: "git" + , pathname: "/halup/Cloud.API.Gateway.git" + , hash: "" + , search: "" + , query: {} + } + ] ]; tester.describe("check urls", test => {