diff --git a/src/repo.ts b/src/repo.ts index a213e2e..299bdbf 100644 --- a/src/repo.ts +++ b/src/repo.ts @@ -37,9 +37,9 @@ const domainToProvider: Record = { "bitbucket.org": "bitbucket", }; -// https://regex101.com/r/NA4Io6/1 +// https://regex101.com/r/Cmuakg/1 const providerURLRegex = - /^(?:(?[\w-]+)@)?(?:(?[^/:]+):)?(?[\w-]+\/(?:\w|\.(?!git$)|-)+)(?:\.git)?$/; + /^(?:(?[\w-]+)@)?(?:(?[^/:]+):)?(?[\w-]+\/(?:\/?\w|\.(?!git$)|-)+)(?:\.git)?$/; function baseUrl(config: RepoConfig) { return `https://${config.domain}/${config.repo}`; diff --git a/test/repo.test.ts b/test/repo.test.ts index c01fba1..2f34ab3 100644 --- a/test/repo.test.ts +++ b/test/repo.test.ts @@ -45,6 +45,14 @@ describe("repo", () => { repo: "b/c", }, }, + { + input: "github:account/project/sub1/sub2/myproject.git", + output: { + domain: "github.com", + provider: "github", + repo: "account/project/sub1/sub2/myproject", + }, + }, ])("url=$input should return RepoConfig", ({ input, output }) => { expect(getRepoConfig(input)).toEqual(output); });