Repository navigation
fix: normalize OpenAI citation markers - #815
Conversation
Little known trick. Closes #684 Assisted-by: gpt-6.1-terra
[Medium impact] The change reaches chat replies and Markdown artifact previews. The PR appears safe to merge, with a non-blocking edge case affecting citation URLs containing numeric dollar amounts. Findings
Fix with agent prompt### Issue 1
ui/src/markdownNormalization.ts:235-239
A completed citation for `https://example.org/prices/$100` becomes `<https://example.org/prices/\$100>`. This replacement creates the link, then `normalizeCurrencyDollars` inserts a backslash. Backslashes are literal inside Markdown autolinks, so clicking the citation opens a different URL.
Keep citation URLs out of the later math and currency changes, and add a test for a URL containing a numeric dollar amount.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryConverts OpenAI citation markers into readable Markdown.
Reviews (1) · Last reviewed commit: "fix: normalize OpenAI citation markers" · Reviewed by Greptile |
| .replace(/\uE200cite\uE202([^\uE200\uE201]*)\uE201/g, (_, sources: string) => | ||
| sources.split("\uE202") | ||
| .filter((source) => /^https?:\/\/[^\s<>]+$/i.test(source)) | ||
| .map((source) => `<${source}>`) | ||
| .join(" ")) |
There was a problem hiding this comment.
A completed citation for https://example.org/prices/$100 becomes <https://example.org/prices/\$100>. This replacement creates the link, then normalizeCurrencyDollars inserts a backslash. Backslashes are literal inside Markdown autolinks, so clicking the citation opens a different URL.
Keep citation URLs out of the later math and currency changes, and add a test for a URL containing a numeric dollar amount.
Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/markdownNormalization.ts
Line: 235-239
Comment:
**Citation URLs can change**
A completed citation for `https://example.org/prices/$100` becomes `<https://example.org/prices/\$100>`. This replacement creates the link, then `normalizeCurrencyDollars` inserts a backslash. Backslashes are literal inside Markdown autolinks, so clicking the citation opens a different URL.
Keep citation URLs out of the later math and currency changes, and add a test for a URL containing a numeric dollar amount.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Little known trick.
Closes #684
Assisted-by: gpt-6.1-terra