Repository navigation
fix(content): read links and page length in time near their size - #1700
Merged
Merged
Conversation
linkKey (server and web) drops a path's trailing slashes by reading back from its end, and textLength / pageTextLength read each tag once, left to right, giving the same counts as before on any markup.
9 of 12 tasks
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.
Summary
Bounds the work on long or unusual input in two small readers the Content Editor and the Content Agent use, so each runs in time near its input's size:
linkKey(servercontent-links.js, weblink-targets.ts): drops a link path's trailing slashes by reading back from the end of the path.textLength(serverpage-content.js) and its web twinpageTextLength(rules.ts): read each tag once, left to right, in three small passes that stand for the three tag regexes they replace.Output is unchanged: the new code gives the same key and the same count as before on every input checked (the existing tests' inputs, the repo's test files and fixtures, and several hundred thousand generated snippets of well-formed and sloppy markup).
Related issue
None.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/content-links.test.js src/lib/content-rewrite.test.js: new cases read long links and long pages with tags left open within a generous time bound.cd web && npx vitest run src/lib/content/link-targets.test.ts src/lib/content/rules.test.ts: the same for the web copies.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code