fix: handle slash branches in GitHub URLs and multi-dot file extensions#2196
Closed
chengyixu wants to merge 1 commit into
Closed
fix: handle slash branches in GitHub URLs and multi-dot file extensions#2196chengyixu wants to merge 1 commit into
chengyixu wants to merge 1 commit into
Conversation
- GitHub blob URL regex now matches branches containing slashes
(e.g., feature/new-validation) by generating candidate branch/path
splits and trying each progressively until one succeeds
- File extension detection now uses the last segment after split('.')
instead of the second segment, supporting filenames like
my.asyncapi.yaml
Fixes asyncapi#1940
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
|
Author
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.



Summary
feature/new-validation)my.asyncapi.yaml)Fixes #1940
Part of microgrant #2125
Changes
1. GitHub URL branch parsing (
src/domains/services/validation.service.ts)The regex
([^\/]+)for branch names did not allow slashes, causing URLs likehttps://github.com/org/repo/blob/feature/new-validation/spec.yamlto fail with 404 errors.Fix: Match everything after
/blob/as a single string, then generate candidate branch/path splits. Try each candidate progressively until one succeeds:main, path=src/file.yaml(most common case, works for simple branches)feature/new-validation, path=spec.yaml(works for slash branches)The resolver's
read()method now tries each candidate in sequence, stopping at the first successful fetch.2. File extension detection (
src/domains/models/SpecificationFile.ts,src/apps/cli/commands/new/file.ts)The old code used
name.split('.')[1]which returns the second segment after splitting by dots. Formy.asyncapi.yaml, this returnedasyncapiinstead ofyaml.Fix: Use
name.split('.')[parts.length - 1]to get the actual file extension (last segment after the final dot).Test plan
yamlinmy.asyncapi.yaml🤖 Generated with Claude Code