From bbcc22746ae0e318e04735bfad45dc1f43b57bbc Mon Sep 17 00:00:00 2001 From: Ben Kircher Date: Wed, 11 Feb 2026 09:47:28 +0100 Subject: [PATCH] urls: fix over-matching single spaced paths This commit adds a negative lookahead `(?!\w+://)` to both `dotted_path_space_segments` and `any_path_space_segments`. This prevents the space-segment matching from consuming text that starts with a URL scheme (like http://), which was causing /tmp/test.txt http://www.google.com to over-match. Fixes https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3882254792 --- src/config/url.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config/url.zig b/src/config/url.zig index 5eb6e26f2..fa902210f 100644 --- a/src/config/url.zig +++ b/src/config/url.zig @@ -61,11 +61,11 @@ const non_dotted_path_lookahead = ; const dotted_path_space_segments = - \\(?: [\w\-.~:\/?#@!$&*+;=%]*[\/.])* + \\(?: (?!\w+:\/\/)[\w\-.~:\/?#@!$&*+;=%]*[\/.])* ; const any_path_space_segments = - \\(?: [\w\-.~:\/?#@!$&*+;=%]+)* + \\(?: (?!\w+:\/\/)[\w\-.~:\/?#@!$&*+;=%]+)* ; // Branch 1: URLs with explicit schemes (http, mailto, ftp, etc.). @@ -226,6 +226,10 @@ test "url regex" { .input = "match git://example.com git links", .expect = "git://example.com", }, + .{ + .input = "/tmp/test.txt http://www.google.com", + .expect = "/tmp/test.txt", + }, .{ .input = "match tel:+18005551234 tel links", .expect = "tel:+18005551234",