From 742c565eeafc05468ba6219b540a871b08b60dc8 Mon Sep 17 00:00:00 2001 From: akash202004 Date: Sun, 28 Dec 2025 23:14:55 +0530 Subject: [PATCH 1/2] fix: resolve github url parsing for slashed branches and improve file extension check --- src/domains/models/SpecificationFile.ts | 2 +- src/domains/services/validation.service.ts | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/domains/models/SpecificationFile.ts b/src/domains/models/SpecificationFile.ts index a0d19f19..21896d18 100644 --- a/src/domains/models/SpecificationFile.ts +++ b/src/domains/models/SpecificationFile.ts @@ -234,7 +234,7 @@ export async function fileExists(name: string): Promise { return true; } - const extension = name.split('.')[1]; + const extension = path.extname(name).substring(1); const allowedExtenstion = ['yml', 'yaml', 'json']; diff --git a/src/domains/services/validation.service.ts b/src/domains/services/validation.service.ts index 1d0dffcf..4f7eb55b 100644 --- a/src/domains/services/validation.service.ts +++ b/src/domains/services/validation.service.ts @@ -68,17 +68,9 @@ const convertGitHubWebUrl = (url: string): string => { // Remove fragment from URL before processing const urlWithoutFragment = url.split('#')[0]; - // Handle GitHub web URLs like: https://github.com/owner/repo/blob/branch/path - // eslint-disable-next-line no-useless-escape - const githubWebPattern = /^https:\/\/github\.com\/([^\/]+)\/([^\/]+)\/blob\/([^\/]+)\/(.+)$/; - const match = urlWithoutFragment.match(githubWebPattern); - - if (match) { - const [, owner, repo, branch, filePath] = match; - return `https://api.github.com/repos/${owner}/${repo}/contents/${filePath}?ref=${branch}`; - } - - return url; + return urlWithoutFragment + .replace('github.com', 'raw.githubusercontent.com') + .replace('/blob/', '/'); }; /** From cff17dfac416287400fb38a50ba3c7bc14995423 Mon Sep 17 00:00:00 2001 From: akash202004 Date: Sun, 28 Dec 2025 23:17:40 +0530 Subject: [PATCH 2/2] chore: add changeset --- .changeset/tender-tigers-shave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tender-tigers-shave.md diff --git a/.changeset/tender-tigers-shave.md b/.changeset/tender-tigers-shave.md new file mode 100644 index 00000000..be292d88 --- /dev/null +++ b/.changeset/tender-tigers-shave.md @@ -0,0 +1,5 @@ +--- +'@asyncapi/cli': minor +--- + +CLI fails for GitHub URLs with slash-based branches and multi-dot spec files