url: fix mid-string dot partial matches

A string like

    foo.local/share

should match fully, not partially.

This commit fixes this by moving `dotted_path_lookahead` before
`bare_relative_path_prefix` so the dot-check scans the entire match
rather than only the text after it.
This commit is contained in:
Ben Kircher
2026-02-08 19:26:31 +01:00
parent d8eb89f384
commit 0f904d92e0

View File

@@ -101,8 +101,8 @@ const bare_relative_path_prefix =
;
const bare_relative_path_branch =
bare_relative_path_prefix ++
dotted_path_lookahead ++
bare_relative_path_prefix ++
path_chars ++ "+" ++
dotted_path_space_segments ++
trailing_spaces_at_eol;
@@ -410,6 +410,11 @@ test "url regex" {
.input = " - shared/src/foo/SomeItem.m:12, shared/src/",
.expect = "shared/src/foo/SomeItem.m:12",
},
// mid-string dot should not partially match but fully
.{
.input = "foo.local/share",
.expect = "foo.local/share",
},
};
for (cases) |case| {
@@ -425,8 +430,8 @@ test "url regex" {
try testing.expectEqualStrings(case.expect, match);
}
// Bare relative paths without any dot should not match as file paths
const no_match_cases = [_][]const u8{
// bare relative paths without any dot should not match as file paths
"input/output",
"foo/bar",
};