Skip to content

fix: handle GitHub URLs with slash-based branches and multi-dot filenames#2198

Open
nguyenquockhang1610 wants to merge 1 commit into
asyncapi:masterfrom
nguyenquockhang1610:fix/github-url-and-extension-parsing
Open

fix: handle GitHub URLs with slash-based branches and multi-dot filenames#2198
nguyenquockhang1610 wants to merge 1 commit into
asyncapi:masterfrom
nguyenquockhang1610:fix/github-url-and-extension-parsing

Conversation

@nguyenquockhang1610
Copy link
Copy Markdown

Summary

Fixes two validation bugs causing valid inputs to fail (#1940).

Bug 1: GitHub URL Parsing

Before: Regex ([^\/]+) for branch only matches single path segment.

https://github.com/org/repo/blob/feature/new-validation/spec.yaml
→ branch="feature", path="new-validation/spec.yaml" ❌

After: Greedy match + intelligent split finds file boundary.

→ branch="feature/new-validation", path="spec.yaml" ✅

Bug 2: File Extension Detection

Before: name.split(".")[1] returns wrong segment for multi-dot names.

"my.asyncapi.yaml".split(".")[1] → "asyncapi" ❌

After: name.split(".").pop() returns last segment.

"my.asyncapi.yaml".split(".").pop() → "yaml" ✅

Files Changed

  • src/domains/services/validation.service.ts — GitHub URL parsing
  • src/domains/models/SpecificationFile.ts — extension detection
  • src/apps/cli/commands/new/file.ts — extension detection

Fixes #1940

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: f1b2a4d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@nguyenquockhang1610 nguyenquockhang1610 force-pushed the fix/github-url-and-extension-parsing branch 2 times, most recently from 5668055 to e0d11c0 Compare May 13, 2026 00:01
…ames

Bug 1: GitHub URL parsing regex assumed branch names don't contain '/'.
URLs like github.com/org/repo/blob/feature/new-validation/spec.yaml
would incorrectly parse 'feature' as the branch and
'new-validation/spec.yaml' as the path.

Fix: Use a greedy match for everything after /blob/ and intelligently
split branch from path by finding the first segment containing a file
extension.

Bug 2: File extension detection used split('.')[1] which fails for
filenames with multiple dots (e.g., 'my.asyncapi.yaml' returns
'asyncapi' instead of 'yaml').

Fix: Use split('.').pop() to get the last extension segment.

Fixes asyncapi#1940
@nguyenquockhang1610 nguyenquockhang1610 force-pushed the fix/github-url-and-extension-parsing branch from e0d11c0 to f1b2a4d Compare May 13, 2026 05:35
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[BUG] CLI fails for GitHub URLs with slash-based branches and multi-dot spec files

1 participant