Skip to content

Conversation

@vaskkey
Copy link
Contributor

@vaskkey vaskkey commented Sep 29, 2025

Marked version: 16.3.0

Markdown flavor: GitHub Flavored Markdown

Description

  • Fixes issue with case-insensitive URL detection for www. prefix
  • Adds support for case-insensitive http and ftp prefixes in text

Expectation

Only lowercase www. should be detected as the start of an autolink. Variants like Www.example.com or WWW.example.com should be treated as plain text, not converted to links.

Case insensitive http or ftp like HtTp"// that is in text e.g. test HTTP://example.com should be autolinked

Result

Previously, the URL regex pattern used the i flag (case-insensitive), causing www., Www., WWW., and other case variations to be detected as autolink starts. This was inconsistent with how GitHub handles autolinks.

What was attempted

Modified the inlineGfm.url regex in src/rules.ts to:

  • Remove the case-insensitive flag ('i')
  • Make protocol detection case-insensitive by replacing the protocol pattern with [fF][tT][pP]|[hH][tT][tT][pP][sS]?
  • Keep www. case-sensitive (lowercase only)

Added test cases to verify:

  • www.example.com - converted to link
  • Www.example.com - plain text
  • WWW.example.com - plain text

Contributor

  • Test(s) exist to ensure functionality and minimize regression (added tests in test/specs/new/autolinks.md and test/specs/new/autolinks.html)
  • No new feature documentation required (bug fix only)

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Sep 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marked-website Ready Ready Preview Comment Oct 4, 2025 6:22am

@gemini-code-assist
Copy link

Summary of Changes

Hello @vaskkey, 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 resolves an inconsistency in autolink detection for www. prefixes, ensuring its behavior matches GitHub Flavored Markdown. Previously, the system would incorrectly autolink Www. or WWW. due to a global case-insensitive regex. The updated logic now recognizes only the lowercase www. as an autolink start, while maintaining explicit case-insensitivity for protocol prefixes like http or ftp. This change improves the accuracy and consistency of Markdown rendering.

Highlights

  • Autolink Detection Consistency: Standardized www. autolink detection to be case-sensitive, aligning with GitHub Flavored Markdown behavior.
  • Regex Refinement: The inlineGfm.url regular expression was modified to remove the global case-insensitive flag, while explicitly making protocol detection (e.g., http, ftp) case-insensitive within the pattern.
  • Enhanced Test Coverage: New test cases were added to validate the correct autolinking behavior for www., Www., and WWW. prefixes.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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 correctly addresses the case-sensitivity of www. autolinks to align with GFM behavior. The change in src/rules.ts is logical, and the new tests in autolinks.md and autolinks.html properly cover the intended fix. However, I've identified a significant related issue: the text parsing rule was not updated along with the url rule. This oversight can lead to incorrect parsing for URLs that use uppercase protocols when they are preceded by other text. I've left a detailed comment on this issue.

@vercel
Copy link

vercel bot commented Oct 3, 2025

@vaskkey is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

@UziTech
Copy link
Member

UziTech commented Oct 4, 2025

/gemini review

Copy link

@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 correctly addresses the case-sensitivity of www. autolinks by removing the case-insensitive flag from the URL regex and explicitly handling case-insensitivity for protocols like http and ftp. The addition of test cases is great for ensuring the fix is working as expected and preventing regressions. I have one minor suggestion in src/rules.ts to improve code maintainability by removing a small inconsistency and duplication.

Copy link
Member

@UziTech UziTech left a comment

Choose a reason for hiding this comment

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

Thanks 💯

@UziTech UziTech merged commit 626d961 into markedjs:master Oct 7, 2025
8 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 7, 2025
# [16.4.0](v16.3.0...v16.4.0) (2025-10-07)

### Bug Fixes

* Fix backtick and code rendering in links ([#3783](#3783)) ([302ee59](302ee59))
* fix links with square brackets in inline code break wrapping italics ([#3785](#3785)) ([e3c0d3e](e3c0d3e))
* Make `www` case-sensitive when detecting link starts ([#3770](#3770)) ([626d961](626d961))

### Features

* Add async provideParser provideLexer ([#3756](#3756)) ([09577e5](09577e5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants