fix: GitHub URL parsing and file extension detection for issue #1940#2141
fix: GitHub URL parsing and file extension detection for issue #1940#2141597226617 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
|
|
|
Hey! Just a friendly bump - this PR has been waiting for review for 3 days. The SonarQube quality gate passed ✅. The changeset-bot warning is expected since this is a bugfix. Let me know if you need any additional information. Thanks! |



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