fix: GitHub URL parsing and file extension detection for issue #1940#2141
Open
597226617 wants to merge 1 commit intoasyncapi:masterfrom
Open
fix: GitHub URL parsing and file extension detection for issue #1940#2141597226617 wants to merge 1 commit intoasyncapi:masterfrom
597226617 wants to merge 1 commit intoasyncapi:masterfrom
Conversation
…pi#1940 - Fix GitHub URL regex to support branch names with slashes (e.g., feature/new-validation) - Fix file extension detection to handle files with multiple dots (e.g., my.asyncapi.yaml) using path.extname() Closes asyncapi#1940
|
|
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.



Description
This PR fixes two bugs reported in issue #1940:
Bug 1: GitHub URL Parsing with Slash-based Branch Names
Problem: The CLI failed to parse GitHub URLs when branch names contained slashes (e.g.,
feature/new-validation).Root Cause: The regex pattern assumed branch names do not contain
/:Fix: Updated the regex to capture the entire branch path (including slashes):
Bug 2: File Extension Detection for Multi-dot Filenames
Problem: Files with multiple dots in the name (e.g.,
my.asyncapi.yaml) were incorrectly parsed.Root Cause: Using
name.split('.')[1]returns the second segment, not the extension:Fix: Use
path.extname()which correctly handles multi-dot filenames:Testing
Both fixes have been tested with multiple test cases:
GitHub URL Parsing Tests
https://github.com/org/repo/blob/feature/new-validation/spec.yamlhttps://github.com/org/repo/blob/main/spec.yamlhttps://github.com/org/repo/blob/feature/branch/name/spec.yamlFile Extension Tests
asyncapi.yaml→yamlmy.asyncapi.yaml→yamltest.v2.asyncapi.yaml→yamlfile.with.many.dots.json→jsonRelated Issue
Closes #1940