Repository navigation
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
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.
Pre-flight checklist
Motivation
shortName(used bydocuHashwhen a generated file name is too long) truncates at a fixed position without looking at character boundaries:U+FFFD. The existing test pins this for a long run of字, with a comment calling it "pretty bad (a character clipped in half)". A long CJK title produces such a route/file name in practice.This change backs off to the previous character boundary in both cases, so the name drops the character that doesn't fit whole instead of keeping a broken half. Names still fit the same limits, and nothing changes for names that don't cut a character.
Test Plan
packages/docusaurus-utils/src/__tests__/pathUtils.test.ts:xfsexpectation for the long字name no longer ends with�. It drops the 82nd character, which doesn't fit whole.does not cut a character in half:'字'.repeat(100)on Linux gives'字'.repeat(81), and`a${'😀'.repeat(200)}`on macOS gives`a${'😀'.repeat(121)}`without a trailing lone surrogate.Without the source change both tests fail (
Received: "字…字�"and"a😀…😀\ud83d"). With it, all 12 tests in the file pass (vitest 5). Formatted withoxfmt.Related issues/PRs
None found.
I used an AI assistant to help write this change. I reproduced the bug, ran the tests and reviewed the diff myself.
Summary by CodeRabbit