UID2-7159: fix highlightJSON rendering spurious space in link_id values with colons#646
Open
sunnywu wants to merge 1 commit into
Open
UID2-7159: fix highlightJSON rendering spurious space in link_id values with colons#646sunnywu wants to merge 1 commit into
sunnywu wants to merge 1 commit into
Conversation
…es with colons Replace the chained-regex approach in highlightJSON with a single-pass tokeniser regex. The previous implementation applied five sequential .replace() calls to the same string; each later pass could re-process content already inside <span> tags inserted by an earlier pass. Colons inside string values (e.g. "azure:eastus2:uuid") caused the number regex to match ":71" and inject a hardcoded ": " prefix, producing a spurious visual space in the service-link admin page output. The new single regex matches quoted strings (with escape-sequence support), keywords, and numbers in one pass, so string content is never re-examined. Adds a Jest test suite (17 tests) covering the regression case and all value types (keys, strings with embedded colons, numbers, booleans, null, array elements, pre-serialised JSON strings). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
highlightJSONinwebroot/js/component/output.jsused five sequential.replace()calls. Each later pass re-processed content already inside<span>tags from earlier passes. Colons inside string values (e.g.azure:eastus2:71ad8e1e-...) caused the step-3 number regex (/:\s*(\d+)/g) to match:71inside the UUID and inject a hardcoded:prefix, producing a spurious visual space on the service-link admin page.webroot/js/component/__tests__/output.test.mjs, 17 tests) covering the regression case and all value types.Test Plan
npm testinwebroot/— 17 tests passlink_id: "azure:eastus2:71ad8e1e-..."renders without spurious spacetrue/false/numbers are not incorrectly highlighted as booleans/numbersJira
UID2-7159
🤖 Generated with Claude Code