fix(scripts): handle CRLF line endings in frontmatter parser for Wind…#505
Open
Rajeevydvv wants to merge 2 commits into
Open
fix(scripts): handle CRLF line endings in frontmatter parser for Wind…#505Rajeevydvv wants to merge 2 commits into
Rajeevydvv wants to merge 2 commits into
Conversation
✅ Deploy Preview for krkn-chaos ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Review Summary by QodoHandle CRLF line endings in frontmatter parser
WalkthroughsDescription• Handle CRLF line endings in frontmatter regex pattern • Split YAML lines using cross-platform regex pattern • Fix silent search index corruption on Windows machines • Clean up trailing whitespace throughout file Diagramflowchart LR
A["Windows CRLF<br/>Line Endings"] -->|"Previously Failed"| B["Frontmatter Regex<br/>with \\n only"]
B --> C["Silent Failure<br/>Empty Metadata"]
C --> D["Broken Search Index"]
A -->|"Now Fixed"| E["Frontmatter Regex<br/>with \\r?\\n"]
E --> F["Correct Metadata<br/>Extraction"]
F --> G["Valid Search Index"]
File Changes1. scripts/build-search-index.js
|
Contributor
Author
|
Hi @paigerube14, could you please review this, open to any changes if needed. |
…ows compatibility Signed-off-by: Rajeev-Cryptographer <Rajeevofficial3@gmail.com>
Signed-off-by: Rajeev-Cryptographer <Rajeevofficial3@gmail.com>
30bd933 to
e68e7ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Fix
Related Feature:
fix/crlf-frontmatter-parserChanges:
The frontmatter parser in
scripts/build-search-index.jsused\n(Unix line endings) in both the regex and string split,causing it to silently fail on Windows machines that use
\r\n(CRLF) line endings.
Root Cause:
Windows contributors cloning this repo get files with CRLF line
endings by default. The frontmatter regex
/^---\n([\s\S]*?)\n---/does not account for
\r— so on Windows, the regex never matches,frontmatterstays as{}, and every document gets indexed withno title, no description, and incorrect content — silently breaking
the entire search index.
Before:
After:
Why this matters:
npm run buildornpm run build:search-indexlocally would get a completelybroken search index with all documents showing as
Untitledno error is thrown, making this extremely hard to debug
\r?\nis the standard cross-platform fix — zero impact onUnix/macOS builds
This is a 2-line change with no impact on production Netlify
builds (which run on Linux) but fixes local development for
all Windows contributors.