fix: handle slashed branch names and multi-dot filenames in GitHub URL parsing#2150
Open
selenaalpha77-sketch wants to merge 2 commits intoasyncapi:masterfrom
Open
fix: handle slashed branch names and multi-dot filenames in GitHub URL parsing#2150selenaalpha77-sketch wants to merge 2 commits intoasyncapi:masterfrom
selenaalpha77-sketch wants to merge 2 commits intoasyncapi:masterfrom
Conversation
…rsing
- convertGitHubWebUrl now converts github.com blob URLs to
raw.githubusercontent.com URLs instead of api.github.com.
This correctly handles branch names containing slashes
(e.g. feature/new-validation) and deeply nested file paths
without needing to split the branch from the file path, since
raw.githubusercontent.com preserves the exact ref+path structure.
- fileExists() in SpecificationFile.ts and the new-file command
now use name.lastIndexOf('.') to extract the file extension,
correctly handling filenames with multiple dots (e.g. my.asyncapi.yaml)
and filenames without any extension.
- Exports convertGitHubWebUrl for unit testing and adds comprehensive
unit tests covering slashed branches, multi-dot filenames, fragments,
non-GitHub URLs, and subdirectory paths.
Fixes asyncapi#1940
🦋 Changeset detectedLatest commit: 5eae4fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Fixes two validation bugs from issue 1940.
1. GitHub URL Parsing - slashed branch names
The previous regex for the branch segment rejected valid URLs like:
https://github.com/org/repo/blob/feature/new-validation/spec.yaml
convertGitHubWebUrl() now converts github.com blob URLs to raw.githubusercontent.com URLs. The raw URL format preserves the exact ref+path structure without needing to split the branch from the file path. The existing resolver already handles raw.githubusercontent.com URLs with the correct Accept header.
2. File Extension Detection - multi-dot filenames
name.split('.')[1] returns the second segment, not the extension. For my.asyncapi.yaml it returns asyncapi instead of yaml, causing the file to be rejected.
Both fileExists() in SpecificationFile.ts and the new file command now use name.lastIndexOf('.') to get the actual extension. Also handles filenames without any extension safely.
Changes