Skip to content

fix(cli): use file URL for config import#3923

Open
Nandann018-ux wants to merge 1 commit intomarkedjs:masterfrom
Nandann018-ux:codex/cli-config-url
Open

fix(cli): use file URL for config import#3923
Nandann018-ux wants to merge 1 commit intomarkedjs:masterfrom
Nandann018-ux:codex/cli-config-url

Conversation

@Nandann018-ux
Copy link

Marked version:

17.0.5

Markdown flavor: n/a

Description

  • Issue: ESM config loading builds a file:/// URL via string concatenation, which doesn’t escape # (and can be invalid on Windows paths). A config path containing # fails to load.
  • Expectation: --config should load any valid file path.
  • Result: marked --config /path/with#hash.js -s "..." fails with module not found.
  • Fix: Use pathToFileURL() for ESM config imports so special characters and Windows paths are encoded correctly.
  • Tests: npm run build, npm run test:unit

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

@vercel
Copy link

vercel bot commented Mar 22, 2026

@Nandann018-ux is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the CLI's ESM config loading mechanism. Previously, config files with special characters in their path, particularly '#', would fail to load because the file:/// URL was constructed via simple string concatenation, leading to invalid URLs. The fix involves adopting Node.js's pathToFileURL() utility to ensure all file paths are correctly encoded into valid file URLs, thereby enhancing the robustness and reliability of config file imports across various file naming conventions and operating systems.

Highlights

  • Fix ESM Config Loading: Resolved an issue where ESM config files failed to load if their path contained special characters like '#' due to improper URL encoding.
  • Robust URL Handling: Implemented pathToFileURL() from Node.js to correctly encode file paths into file:/// URLs, ensuring compatibility with special characters and Windows paths.
  • New Test Case: Added a dedicated unit test to verify that config files with '#' in their path are now loaded successfully.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug in the CLI where loading an ESM configuration file fails if the file path contains a hash (#) character. The fix replaces manual string concatenation for creating a file:/// URL with the pathToFileURL function, which correctly handles special characters and platform-specific path formats. A new unit test is included to verify that configuration files with a hash in the name can be imported successfully. The changes are correct and well-tested.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant