Skip to content

fix(grid): keep surrounding text and code out of detected URL links - #102

Merged
simota merged 1 commit into
mainfrom
fix/url-detection-boundaries
Oct 16, 2026
Merged

simota merged 1 commit into
mainfrom
fix/url-detection-boundaries

Conversation

@simota

@simota simota commented Oct 16, 2026

Copy link
Copy Markdown
Owner

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 $ or user@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:

  • The change is confined to noa-grid URL detection (url.rs), plus
    doc-comment updates in path.rs; there are no API or protocol changes.
  • Shell prompts are recognized by a terminator character ($ % # > ❯ ➜ λ »)
    followed by whitespace. A redirection directly before a quoted URL
    (echo x > 'https://…'foo'bar') is treated like a prompt; this is
    considered rare in real output.

Validation:

  • cargo fmt --all -- --check passed.
  • cargo test --workspace --locked --offline --quiet --no-fail-fast
    passed: 2,819 passed, 0 failed, 15 existing ignored tests.
  • cargo clippy -p noa-grid --all-targets --locked --offline -- -D warnings passed.
  • The shell-prompt regression test fails without prompt stripping
    ($ curl 'https://example.com/path'foo'bar' resolved to
    https://example.com/path'foo'bar) and passes with it.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T13:34:05.866831Z af4edb1 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@simota
simota merged commit 19ac73a into main Oct 16, 2026
1 check passed
@simota
simota deleted the fix/url-detection-boundaries branch October 16, 2026 13:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +753 to +757
if !in_query_or_fragment {
while end > authority_start && TRAILING_PUNCTUATION.contains(&chars[end - 1]) {
end -= 1;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant