url: fix comma handling

This string

    foo/bar,baz.txt

should not match but

    src/foo.c,baz.txt

should.

Remove `,` from dotted_path_lookahead and non_dotted_path_lookahead.
This commit is contained in:
Ben Kircher
2026-02-09 09:21:01 +01:00
parent 19a41eb26b
commit 02749cb1dc

View File

@@ -53,11 +53,11 @@ const trailing_spaces_at_eol =
;
const dotted_path_lookahead =
\\(?=[\w\-.~:\/?#@!$&*+,;=%]*\.)
\\(?=[\w\-.~:\/?#@!$&*+;=%]*\.)
;
const non_dotted_path_lookahead =
\\(?![\w\-.~:\/?#@!$&*+,;=%]*\.)
\\(?![\w\-.~:\/?#@!$&*+;=%]*\.)
;
const dotted_path_space_segments =
@@ -369,6 +369,11 @@ test "url regex" {
.input = "some-pkg/src/file.txt more text",
.expect = "some-pkg/src/file.txt",
},
// comma should match substrings
.{
.input = "src/foo.c,baz.txt",
.expect = "src/foo.c",
},
.{
.input = "~/foo/bar.txt",
.expect = "~/foo/bar.txt",
@@ -452,6 +457,8 @@ test "url regex" {
"$10/bar",
"$10/$20",
"$10/bar.txt",
// comma should not let dot detection look past it
"foo/bar,baz.txt",
};
for (no_match_cases) |input| {
var result = re.search(input, .{});