From b6f7248e73ee3adea1f4ebfddb72f4ed854c41b1 Mon Sep 17 00:00:00 2001 From: messiawrq-design Date: Sat, 30 May 2026 00:16:17 +0000 Subject: [PATCH] fix(cli): correct GitHub URL branch parsing and file extension detection Fixes #1940. 1. Updated `githubWebPattern` in `validation.service.ts` from `([^\/]+)` to `(.+?)` for the branch capture group. This correctly allows URLs with slash-based branch names (e.g., `feature/new-validation`) to be parsed instead of throwing a 404. 2. Updated extension extraction in `SpecificationFile.ts` to use the last element of the split array (`parts[parts.length - 1]`), which gracefully supports multi-dot filenames like `my.asyncapi.yaml` and files with no extensions. Bounty Wallet: 6sF8p22Gg83NKTJ6dvya7Srv4USCniZnP47DwQwK7Mtp (Solana) / Algora --- src/domains/models/SpecificationFile.ts | 3 ++- src/domains/services/validation.service.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/domains/models/SpecificationFile.ts b/src/domains/models/SpecificationFile.ts index 5370f6e67..7694a1dd7 100644 --- a/src/domains/models/SpecificationFile.ts +++ b/src/domains/models/SpecificationFile.ts @@ -237,7 +237,8 @@ export async function fileExists(name: string): Promise { return true; } - const extension = name.split('.')[1]; + const parts = name.split('.'); + const extension = parts.length > 1 ? parts[parts.length - 1] : ''; const allowedExtenstion = ['yml', 'yaml', 'json']; diff --git a/src/domains/services/validation.service.ts b/src/domains/services/validation.service.ts index 11ac45fc4..c7932d75b 100644 --- a/src/domains/services/validation.service.ts +++ b/src/domains/services/validation.service.ts @@ -70,7 +70,7 @@ const convertGitHubWebUrl = (url: string): string => { // 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 githubWebPattern = /^https:\/\/github\.com\/([^\/]+)\/([^\/]+)\/blob\/(.+?)\/(.+)$/; const match = urlWithoutFragment.match(githubWebPattern); if (match) {