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
5 changes: 5 additions & 0 deletions .changeset/tender-tigers-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@asyncapi/cli': minor
---

CLI fails for GitHub URLs with slash-based branches and multi-dot spec files
2 changes: 1 addition & 1 deletion src/domains/models/SpecificationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export async function fileExists(name: string): Promise<boolean> {
return true;
}

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

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

Expand Down
14 changes: 3 additions & 11 deletions src/domains/services/validation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/', '/');
};

/**
Expand Down
Loading