Repository navigation
fix(grid): keep surrounding text and code out of detected URL links - #102
Conversation
Cmd+click opened the wrong address whenever a URL sat inside code, logs, or prose: closing quotes, trailing expressions, SQL literals, shell word concatenations, and CJK punctuation were absorbed into the link, and a redirect URL embedded in a query could hijack the outer link on hover. URL ends are now decided from the quoting context around the match (single, triple, and SQL quotes, shell commands with or without a prompt) and from bracket balance, so delimiters bound the link while balanced brackets, IPv6 hosts, and non-ASCII path characters stay inside it.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af4edb109f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !in_query_or_fragment { | ||
| while end > authority_start && TRAILING_PUNCTUATION.contains(&chars[end - 1]) { | ||
| end -= 1; | ||
| } | ||
| } |
There was a problem hiding this comment.
Trim sentence punctuation after queries and fragments
When a URL containing ? or # appears in prose, this condition disables all trailing-punctuation trimming, so text such as See https://example.com/search?q=rust, next or https://example.com/page#intro. produces a link ending in , or .. These are common URL forms, and the previous detector trimmed that decoration; retain query punctuation internally but still remove terminal sentence punctuation at the run boundary.
Useful? React with 👍 / 👎.
Cmd+click opened the wrong address whenever a URL sat inside code, logs,
or prose. Closing quotes, trailing expressions, SQL literals, shell word
concatenations, and CJK punctuation were absorbed into the link, and a
redirect URL embedded in a query could take over the outer link on hover.
URL ends are now decided from the quoting context around the match
(single, triple, and SQL quotes; shell commands with or without a
leading prompt such as
$oruser@host:~$) and from bracket balance.Delimiters bound the link, while balanced brackets, IPv6 hosts, and
non-ASCII path and domain characters stay inside it. URLs are visited in
text order and their contents skipped, so a nested URL cannot override
the one containing it.
Notes for review:
noa-gridURL detection (url.rs), plusdoc-comment updates in
path.rs; there are no API or protocol changes.$ % # > ❯ ➜ λ »)followed by whitespace. A redirection directly before a quoted URL
(
echo x > 'https://…'foo'bar') is treated like a prompt; this isconsidered rare in real output.
Validation:
cargo fmt --all -- --checkpassed.cargo test --workspace --locked --offline --quiet --no-fail-fastpassed: 2,819 passed, 0 failed, 15 existing ignored tests.
cargo clippy -p noa-grid --all-targets --locked --offline -- -D warningspassed.(
$ curl 'https://example.com/path'foo'bar'resolved tohttps://example.com/path'foo'bar) and passes with it.