Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/unix-manual-regex-lastindex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@node-core/doc-kit': patch
---

Fix `isTextWithUnixManual` intermittently missing valid Unix manual page
references: the shared `unixManualPage` regex is global, so its `lastIndex`
persisted between `.test()` calls during tree traversal.
6 changes: 4 additions & 2 deletions src/utils/queries/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export const UNIST = {
* @param {import('@types/mdast').Text} text
* @returns {boolean}
*/
isTextWithUnixManual: ({ type, value }) =>
type === 'text' && QUERIES.unixManualPage.test(value),
isTextWithUnixManual: ({ type, value }) => {
QUERIES.unixManualPage.lastIndex = 0; // Reset the lastIndex to ensure proper matching
return type === 'text' && QUERIES.unixManualPage.test(value);
},
Comment thread
btea marked this conversation as resolved.

/**
* @param {import('@types/mdast').Link} link
Expand Down
Loading