fix: support slash-based branch names in GitHub URLs and multi-dot file extensions#2206
Open
XuanYuandp wants to merge 2 commits into
Open
Conversation
…le extensions Fixes asyncapi#1940 Two bugs fixed: 1. GitHub URL parsing regex assumed branch names don't contain '/'. This caused URLs like github.com/org/repo/blob/feature/new-validation/spec.yaml to be incorrectly parsed, extracting only 'feature' as the branch name. Fixed by using a heuristic to find the correct branch/path split point. 2. File extension detection used `name.split('.')[1]` which returns the wrong segment for multi-dot filenames like `my.asyncapi.yaml`. Fixed by using `.pop()` to always get the last segment (actual extension). Files changed: - src/domains/services/validation.service.ts: Fix GitHub URL regex - src/domains/models/SpecificationFile.ts: Fix extension detection - src/apps/cli/commands/new/file.ts: Fix extension detection - test/unit/services/validation.service.test.ts: Add test for slash branches
🦋 Changeset detectedLatest commit: 0f85c3d 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 Opus 4.7 <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 this does
Fixes #1940 — Two validation bugs causing valid inputs to fail.
Bug 1: GitHub URL Parsing
The regex assumed branch names don't contain
/. URLs likegithub.com/org/repo/blob/feature/new-validation/spec.yamlwere incorrectly parsed, extracting onlyfeatureas the branch.Fix: Changed regex to capture everything after
/blob/, then uses a heuristic to find the correct branch/path split point.Bug 2: File Extension Detection
Used
name.split('.')[1]which returns the wrong segment for multi-dot filenames likemy.asyncapi.yaml(returnsasyncapiinstead ofyaml).Fix: Changed to
name.split('.').pop()to always get the last segment.Files changed
src/domains/services/validation.service.ts— Fix GitHub URL regexsrc/domains/models/SpecificationFile.ts— Fix extension detectionsrc/apps/cli/commands/new/file.ts— Fix extension detectiontest/unit/services/validation.service.test.ts— Add test for slash-based branch namesTesting
All 9 tests passing including new test for slash-based branch name parsing.
Part of MICROGRANT Program 2026-05 (references #1940).