Skip to content

fix: support slash-based branch names in GitHub URLs and multi-dot file extensions#2212

Closed
ghost wants to merge 1 commit into
masterfrom
unknown repository
Closed

fix: support slash-based branch names in GitHub URLs and multi-dot file extensions#2212
ghost wants to merge 1 commit into
masterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented May 23, 2026

Description

This PR resolves two validation and parsing issues under issue #1940:

  1. GitHub URL Parsing (validation.service.ts):
    Replaces the greedy regular-expression-based parsing of remote GitHub blob URLs in convertGitHubWebUrl() with a direct, robust conversion to raw.githubusercontent.com. This natively supports branches with slashes (e.g. feature/new-validation), tags, and commit SHAs without any local string-splitting or extra API roundtrips.
  2. File Extension Detection (SpecificationFile.ts):
    Updates fileExists() to retrieve the file extension using .pop() instead of [1]. This ensures multi-dot files like my.asyncapi.yaml are correctly classified, and extension-less files are handled gracefully instead of throwing runtime exceptions.
  3. Try-Catch Isolation (SpecificationFile.ts):
    Isolates the try-catch block in fileExists() to ONLY the lstat call, preventing the masking of 'invalid file' errors.
  4. Changeset & Conventional Commit:
    Added the required changeset file under .changeset/ for patch version bumping.

Fixes #1940
Fixes #2125

Verification

  • Added comprehensive unit tests for convertGitHubWebUrl() validating branch names with slashes, tags, and commit SHAs.
  • Added file-system-based unit tests for fileExists() using temporary directories.
  • Ran npm run unit:test (68/68 unit tests passed cleanly).
  • Ran npm run lint (0 lint errors).
  • Ran npm run build (Build completed successfully).

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 23, 2026

🦋 Changeset detected

Latest commit: af091cc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

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

@sonarqubecloud
Copy link
Copy Markdown

@ghost ghost closed this May 25, 2026
@github-project-automation github-project-automation Bot moved this from To Triage to Done in CLI - Kanban May 25, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Set of issues for resolution under the MICROGRANT Program 2026-05 [BUG] CLI fails for GitHub URLs with slash-based branches and multi-dot spec files

0 participants