url: allow numeric characters at start

Amends and fixes the last commit which was too simpel. This commit uses
a lookbehind to prevent matching $-numeric patterns.
This commit is contained in:
Ben Kircher
2026-02-08 22:25:35 +01:00
parent 99320714bc
commit 19a41eb26b

View File

@@ -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 =
\\[A-Za-z_][\w\-.]*\/
\\(?<!\$\d*)[\w][\w\-.]*\/
;
const bare_relative_path_branch =
@@ -424,6 +424,11 @@ test "url regex" {
.input = "foo.local/share",
.expect = "foo.local/share",
},
// numeric directory should match fully
.{
.input = "2024/report.txt",
.expect = "2024/report.txt",
},
};
for (cases) |case| {