Skip to content

fix: support slash-based branch names and multi-dot file extensions in GitHub URL parsing#2132

Open
useye wants to merge 2 commits intoasyncapi:masterfrom
useye:fix-issue-1940
Open

fix: support slash-based branch names and multi-dot file extensions in GitHub URL parsing#2132
useye wants to merge 2 commits intoasyncapi:masterfrom
useye:fix-issue-1940

Conversation

@useye
Copy link
Copy Markdown

@useye useye commented Apr 22, 2026

Description

Fixes #1940

This PR fixes two bugs in the CLI:

1. GitHub URL Parsing Bug

Problem: The regex pattern assumed branch names don't contain /, causing failures for valid URLs like:

https://github.com/org/repo/blob/feature/new-validation/spec.yaml

Solution: Rewrote the URL parsing logic to:

  • Parse owner, repo, and the combined branch+path
  • Work backwards from the filename to separate branch from file path
  • Correctly handle branch names with slashes

2. File Extension Detection Bug

Problem: Used name.split('.')[1] which fails for:

  • Files with multiple dots: my.asyncapi.yaml → incorrectly gets "asyncapi" instead of "yaml"
  • Files without extensions: asyncapi → undefined, causes crash

Solution:

  • Use .pop() to get the last segment after splitting by .
  • Add proper undefined check for files without extensions
  • Convert to lowercase for case-insensitive comparison

Testing:

  • GitHub URL with slash-based branch (e.g. feature/new-validation) works correctly
  • Multi-dot filenames (e.g. my.asyncapi.yaml) are validated correctly
  • Files without extensions don't cause crashes

useye added 2 commits April 22, 2026 11:05
Fixes asyncapi#1940 - GitHub URLs with branch names containing slashes (e.g. feature/new-validation) were being incorrectly parsed, causing 404 errors.
Fixes asyncapi#1940 - Files like my.asyncapi.yaml were incorrectly validated because split('.')[1] returns 'asyncapi' instead of 'yaml'. Now using pop() to get the last segment.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

⚠️ No Changeset found

Latest commit: 1ac5021

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@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