Skip to content

Conversation

@akash202004
Copy link

@akash202004 akash202004 commented Dec 28, 2025

fix: github url parsing and file extension validation

Summary

This PR fixes two validation bugs that caused the CLI to fail for valid GitHub URLs and specification filenames.

  • Replaced brittle regex-based GitHub URL parsing with a deterministic transformation to raw.githubusercontent.com, correctly supporting branch names that contain slashes.
  • Replaced manual file extension parsing using split('.') with path.extname(), correctly handling multi-dot filenames and no-extension edge cases.

Changes

  • GitHub URL handling: Simplified URL processing by removing branch parsing logic and delegating resolution to GitHub’s raw content endpoint.
  • File extension validation: Improved robustness by using Node.js standard library APIs for extension detection.

Verification

  • Ran the full CLI test suite:
npm run cli:test
Exit Code: 0
  • Manually verified behavior for:
    • GitHub URLs with slash-based branch names
    • Multi-dot specification filenames
    • Files without extensions

Result

The CLI now correctly processes all valid GitHub file URLs and specification files without false rejections or runtime failures.

#1940

@changeset-bot
Copy link

changeset-bot bot commented Dec 28, 2025

🦋 Changeset detected

Latest commit: cff17df

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 Minor

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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 28, 2025

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 No release type found in pull request title "Fix/GitHub url parsing and extension check". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

2 participants