Skip to content

The agent that grows with you

fix(desktop): keep www.-prefixed local paths literal in explicit-only linkify

Austin Pickettb8ac495fa19f
diff --git a/apps/desktop/src/lib/external-link.test.tsx b/apps/desktop/src/lib/external-link.test.tsx
index ab1fdb4b4ac..7255abab667 100644
--- a/apps/desktop/src/lib/external-link.test.tsx
+++ b/apps/desktop/src/lib/external-link.test.tsx
@@ -335,6 +335,21 @@ describe('external link helpers', () => {
expect(links.some(a => (a.textContent ?? '').includes('.log'))).toBe(false)
})
+ it('explicitOnly keeps www.-prefixed local filenames literal but links a standalone www. URL', () => {
+ installDesktopBridge()
+
+ render(
+ <LinkifiedText
+ explicitOnly
+ pretty={false}
+ text={'wrote /tmp/www.config and C:\\Users\\test-user\\Documents\\www.config; docs at www.example.com'}
+ />
+ )
+
+ const links = screen.getAllByRole('link')
+ expect(links.map(a => a.getAttribute('href'))).toEqual(['https://www.example.com'])
+ })
+
it('without explicitOnly, bare filename tokens are still linkified (default behavior)', () => {
installDesktopBridge()
diff --git a/apps/desktop/src/lib/external-link.tsx b/apps/desktop/src/lib/external-link.tsx
index 83ede9456ea..ea5b693e470 100644
--- a/apps/desktop/src/lib/external-link.tsx
+++ b/apps/desktop/src/lib/external-link.tsx
@@ -19,8 +19,9 @@ const URL_RE =
// Explicit-scheme / www. URLs only — no bare-domain matching. Used where the
// surrounding text is full of filename-shaped tokens (e.g. `agent.log`,
// `errors.log` in a /debug report) that the bare-domain branch of URL_RE would
-// otherwise mistake for domains and linkify.
-const EXPLICIT_URL_RE = /(?:https?:\/\/|www\.)[^\s<>"'`]+[^\s<>"'`.,;:!?)]/gi
+// otherwise mistake for domains and linkify. A `www.` match must not continue a
+// path or word (`/tmp/www.config`, `C:\…\www.config` stay literal).
+const EXPLICIT_URL_RE = /(?:https?:\/\/|(?<![\w.\-/\\@])www\.)[^\s<>"'`]+[^\s<>"'`.,;:!?)]/gi
const DOMAIN_RE = /^(?:www\.)?[a-z0-9](?:[a-z0-9-]*\.)+[a-z]{2,}(?::\d+)?(?:[/?#][^\s]*)?$/i
const SKIP_PROTO_RE = /^(?:file|data|mailto|javascript|blob|chrome|about|hermes):/i