mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 14:00:29 +00:00
url: fix incomplete $-numeric behavior
This
$10/bar.txt
was partially matching but should not match at all.
This commit fixes this by simply `[\w]` to `[A-Za-z_]` as the first
character of a bare relative path, so digit-starting fragments can't
match.
Another option would be a lookbehind but I think the check above is much
simpler.
This commit is contained in:
@@ -97,7 +97,7 @@ const rooted_or_relative_path_branch =
|
||||
|
||||
// Branch 3: Bare relative paths such as src/config/url.zig.
|
||||
const bare_relative_path_prefix =
|
||||
\\[\w][\w\-.]*\/
|
||||
\\[A-Za-z_][\w\-.]*\/
|
||||
;
|
||||
|
||||
const bare_relative_path_branch =
|
||||
@@ -446,6 +446,7 @@ test "url regex" {
|
||||
// $-numeric character should not match
|
||||
"$10/bar",
|
||||
"$10/$20",
|
||||
"$10/bar.txt",
|
||||
};
|
||||
for (no_match_cases) |input| {
|
||||
var result = re.search(input, .{});
|
||||
|
||||
Reference in New Issue
Block a user