Skip to content

fix(slugger): optimize trailing/leading regex#610

Open
avivkeller wants to merge 3 commits intomainfrom
regex-is-nuts
Open

fix(slugger): optimize trailing/leading regex#610
avivkeller wants to merge 3 commits intomainfrom
regex-is-nuts

Conversation

@avivkeller
Copy link
Member

@avivkeller avivkeller requested a review from a team as a code owner February 16, 2026 22:35
Copilot AI review requested due to automatic review settings February 16, 2026 22:35
@vercel
Copy link

vercel bot commented Feb 16, 2026

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

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Feb 16, 2026 10:40pm

Request Review

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.65%. Comparing base (a8aacc8) to head (6c35d81).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
- Coverage   78.66%   78.65%   -0.01%     
==========================================
  Files         128      128              
  Lines       12456    12454       -2     
  Branches      883      883              
==========================================
- Hits         9798     9796       -2     
  Misses       2653     2653              
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Feb 16, 2026

legacy-html Generator

File Base Head Diff
cli.html 281.51 KB 283.20 KB +1.69 KB (+0.60%)
deprecations.html 258.86 KB 258.89 KB +32.00 B (+0.01%)
single-executable-applications.html 83.02 KB 83.05 KB +24.00 B (+0.03%)
esm.html 122.59 KB 122.60 KB +16.00 B (+0.01%)
globals.html 120.17 KB 120.18 KB +16.00 B (+0.01%)
modules.html 148.53 KB 148.55 KB +16.00 B (+0.01%)
buffer.html 1.06 MB 1.06 MB +8.00 B (+0.00%)
packages.html 118.86 KB 118.87 KB +8.00 B (+0.01%)
repl.html 215.26 KB 215.26 KB +8.00 B (+0.00%)
tls.html 259.31 KB 259.32 KB +8.00 B (+0.00%)
module.html 322.94 KB 322.94 KB +4.00 B (+0.00%)
webstreams.html 266.19 KB 266.20 KB +4.00 B (+0.00%)

orama-db Generator

File Base Head Diff
orama-db.json 8.03 MB 8.03 MB +3.29 KB (+0.04%)

web Generator

File Base Head Diff
cli.js 325.51 KB 327.85 KB +2.34 KB (+0.72%)
cli.html 502.93 KB 504.50 KB +1.57 KB (+0.31%)
deprecations.js 313.52 KB 313.57 KB +48.00 B (+0.01%)
single-executable-applications.js 83.41 KB 83.45 KB +36.00 B (+0.04%)
deprecations.html 509.91 KB 509.94 KB +32.00 B (+0.01%)
globals.js 139.24 KB 139.26 KB +24.00 B (+0.02%)
modules.js 158.24 KB 158.26 KB +24.00 B (+0.01%)
single-executable-applications.html 101.24 KB 101.26 KB +24.00 B (+0.02%)
globals.html 231.61 KB 231.62 KB +16.00 B (+0.01%)
modules.html 177.98 KB 177.99 KB +16.00 B (+0.01%)
buffer.js 1.13 MB 1.13 MB +12.00 B (+0.00%)
packages.js 126.22 KB 126.24 KB +12.00 B (+0.01%)
tls.js 349.38 KB 349.40 KB +12.00 B (+0.00%)
buffer.html 855.53 KB 855.54 KB +8.00 B (+0.00%)
esm.html 152.69 KB 152.70 KB +8.00 B (+0.01%)
esm.js 139.78 KB 139.79 KB +8.00 B (+0.01%)
packages.html 155.45 KB 155.46 KB +8.00 B (+0.01%)
tls.html 353.23 KB 353.24 KB +8.00 B (+0.00%)
repl.html 176.85 KB 176.86 KB +4.00 B (+0.00%)
repl.js 215.40 KB 215.40 KB +4.00 B (+0.00%)
module.html 310.90 KB 310.91 KB +2.00 B (+0.00%)
module.js 351.50 KB 351.50 KB +2.00 B (+0.00%)
webstreams.html 343.87 KB 343.87 KB +2.00 B (+0.00%)
webstreams.js 320.81 KB 320.82 KB +2.00 B (+0.00%)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Node.js API doc slug normalization logic by consolidating the “trim leading/trailing hyphen” behavior into a single regex replacement in the parser constants.

Changes:

  • Replaces two separate leading/trailing hyphen replacements with one combined regex in DOC_API_SLUGS_REPLACEMENTS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@avivkeller
Copy link
Member Author

Note: The anchors are slightly different (i.e. --my-flag's anchor is --my-flag instead of -my-flag)

{ from: /--+/g, to: '-' }, // Replace multiple hyphens with single
{ from: /^-/, to: '' }, // Remove any leading hyphen
{ from: /-$/, to: '' }, // Remove any trailing hyphen
{ from: /^-(?!$|-)|(?<!^|-)-$/g, to: '' }, // Remove any trailing or leading hyphen
Copy link
Member

@MattIPv4 MattIPv4 Feb 16, 2026

Choose a reason for hiding this comment

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

Suggested change
{ from: /^-(?!$|-)|(?<!^|-)-$/g, to: '' }, // Remove any trailing or leading hyphen
{ from: /^-+(?!-*$)/g, to: '' }, // Remove any leading hyphens
{ from: /(?<!^-*)-+$/g, to: '' }, // Remove any trailing hyphens

I think this does the same, but is a bit clearer to me, matching one or more hyphens, as long as we don't see the start/end around.

Copy link
Member

Choose a reason for hiding this comment

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

{ from: /node.js/i, to: 'nodejs' }, // Replace Node.js
{ from: /&/, to: '-and-' }, // Replace &
{ from: /[/_,:;\\ ]/g, to: '-' }, // Replace /_,:;\. and whitespace
{ from: /--+/g, to: '-' }, // Replace multiple hyphens with single
Copy link
Member

Choose a reason for hiding this comment

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

I think we probably want to keep this deduplication somehow?

Copy link
Member

Choose a reason for hiding this comment

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

(?<!^-*)--+(?!-*$) might work for this?

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.

2 participants