Skip to content

Fix source audit issues in content utilities and sidebar#8200

Closed
arechaithanya wants to merge 1 commit intowebpack:mainfrom
arechaithanya:codex/fix-source-audit-issues
Closed

Fix source audit issues in content utilities and sidebar#8200
arechaithanya wants to merge 1 commit intowebpack:mainfrom
arechaithanya:codex/fix-source-audit-issues

Conversation

@arechaithanya
Copy link
Copy Markdown
Contributor

@arechaithanya arechaithanya commented Apr 17, 2026

Summary

This PR fixes several correctness issues found during an audit of /src.

Changes include:

  • Guarding sparse refractor/HAST token nodes before reading className, nested children, or values.
  • Replacing Array#map() side-effect usage in flatten-content-tree with for...of.
  • Removing an unreachable if (page) branch in getPageTitle.
  • Switching content tree anchor extraction to processSync() so synchronous build output does not depend on callback timing.
  • Avoiding unconditional ... on blog teasers when the teaser was not truncated.
  • Preserving additional hash fragments when lowercasing README link anchors.
  • Replacing a custom getMatches() helper with native String.prototype.matchAll().
  • Replacing sidebar RegExp URL matching with normalized string comparison so URL path characters are treated literally.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes. I added regression coverage for:

  • sidebar paths containing RegExp-special characters
  • blog teasers that should not receive an ellipsis when untruncated
  • blog teasers that should receive an ellipsis when truncated
  • README links with multiple hash fragments

Validated with:

npm run jest -- src/components/SidebarItem/SidebarItem.test.jsx src/utilities/content-tree-enhancers.test.mjs src/utilities/process-readme.test.mjs src/utilities/content-utils.test.mjs

npm run lint:js -- src/components/SidebarItem/SidebarItem.jsx src/components/SidebarItem/SidebarItem.test.jsx src/remark-plugins/remark-refractor/index.mjs src/utilities/content-tree-enhancers.mjs src/utilities/content-tree-enhancers.test.mjs src/utilities/content-utils.mjs src/utilities/flatten-content-tree.mjs src/utilities/process-readme.mjs src/utilities/process-readme.test.mjs

npx prettier --check src/components/SidebarItem/SidebarItem.jsx src/components/SidebarItem/SidebarItem.test.jsx src/remark-plugins/remark-refractor/index.mjs src/utilities/content-tree-enhancers.mjs src/utilities/content-tree-enhancers.test.mjs src/utilities/content-utils.mjs src/utilities/flatten-content-tree.mjs src/utilities/process-readme.mjs src/utilities/process-readme.test.mjs

git diff --check

The repository pre-commit hook also passed.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

No documentation changes are required. These are internal source fixes.

Use of AI

I used AI assistance to audit the source files, identify fragile logic, draft the fixes, and prepare regression tests. I reviewed the changes and validated them with the repository’s test, lint, and formatting checks before pushing.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

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

Project Deployment Actions Updated (UTC)
webpack-js-org Ready Ready Preview, Comment Apr 17, 2026 3:37pm

Request Review

Copy link
Copy Markdown
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Looks like AI generated

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.

3 participants