url: fix , handling for spaced paths

Update path_space_segments patterns to consistently handle
comma-delimiters.
This commit is contained in:
Ben Kircher
2026-02-09 10:50:31 +01:00
parent 38831436ea
commit 23d22c457a

View File

@@ -61,11 +61,11 @@ const non_dotted_path_lookahead =
;
const dotted_path_space_segments =
\\(?: [\w\-.~:\/?#@!$&*+,;=%]*[\/.])*
\\(?: [\w\-.~:\/?#@!$&*+;=%]*[\/.])*
;
const any_path_space_segments =
\\(?: [\w\-.~:\/?#@!$&*+,;=%]+)*
\\(?: [\w\-.~:\/?#@!$&*+;=%]+)*
;
// Branch 1: URLs with explicit schemes (http, mailto, ftp, etc.).
@@ -434,6 +434,15 @@ test "url regex" {
.input = "2024/report.txt",
.expect = "2024/report.txt",
},
// comma should stop matching in spaced path segments
.{
.input = "./foo bar,baz",
.expect = "./foo bar",
},
.{
.input = "/tmp/foo bar,baz",
.expect = "/tmp/foo bar",
},
};
for (cases) |case| {