Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/fix-github-url-parsing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@asyncapi/cli': patch
---

fix: github URL parsing for slash-based branches and multi-dot filenames

- Update GitHub blob URL regex to support branch names with slashes (e.g., feature/new-validation)
- Use path.extname() instead of split('.') for reliable file extension detection
- Fixes issue #1940 where URLs with slash-based branch names failed to parse
2 changes: 1 addition & 1 deletion src/domains/models/SpecificationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export async function fileExists(name: string): Promise<boolean> {
return true;
}

const extension = name.split('.')[1];
const extension = path.extname(name).slice(1).toLowerCase();

const allowedExtenstion = ['yml', 'yaml', 'json'];

Expand Down
3 changes: 2 additions & 1 deletion src/domains/services/validation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ const convertGitHubWebUrl = (url: string): string => {
const urlWithoutFragment = url.split('#')[0];

// Handle GitHub web URLs like: https://github.com/owner/repo/blob/branch/path
// Updated to support branch names with slashes (e.g., feature/new-validation)
// 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) {
Expand Down
Loading