diff --git a/package.json b/package.json index 3725c98..a644624 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "build": "tsc", "test": "jest", "test:watch": "jest --watch", - "prepublishOnly": "npm run build" + "prepublishOnly": "npm run build", + "prepare": "npm run build" }, "homepage": "https://github.com/Jno21/semantic-release-github-commit#readme", "keywords": [ diff --git a/src/utils.ts b/src/utils.ts index 5ce6464..b2473da 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -33,11 +33,14 @@ export function parseRepositoryUrl(url: string): { // - https://github.com/owner/repo // - owner/repo - let match = url.match(/github\.com[:/]([^/]+)\/([^/.]+)/); + // First, remove `.git` if it exists + let sanitizedUrl = url.replace(/\.git$/, ""); + + let match = sanitizedUrl.match(/github\.com[:/]([^/]+)\/([^/?#]+)/); if (!match) { // Try simple owner/repo format - match = url.match(/^([^/]+)\/([^/]+)$/); + match = sanitizedUrl.match(/^([^/]+)\/([^/]+)$/); } if (!match) { @@ -45,7 +48,7 @@ export function parseRepositoryUrl(url: string): { } const owner = match[1]; - const repo = match[2].replace(/\.git$/, ""); + const repo = match[2]; return { owner, repo }; }