url: do not match on //

Double-slash comments are not paths so do not match on them.
This commit is contained in:
Ben Kircher
2026-02-09 11:10:51 +01:00
parent 23d22c457a
commit 50ba394ed3

View File

@@ -75,7 +75,7 @@ const scheme_url_branch =
no_trailing_punctuation;
const rooted_or_relative_path_prefix =
\\(?:\.\.\/|\.\/|(?<!\w)~\/|(?:[\w][\w\-.]*\/)*(?<!\w)\$[A-Za-z_]\w*\/|\.[\w][\w\-.]*\/|(?<![\w~])\/)
\\(?:\.\.\/|\.\/|(?<!\w)~\/|(?:[\w][\w\-.]*\/)*(?<!\w)\$[A-Za-z_]\w*\/|\.[\w][\w\-.]*\/|(?<![\w~\/])\/(?!\/))
;
// Branch 2: Absolute paths and dot-relative paths (/, ./, ../).
@@ -472,6 +472,9 @@ test "url regex" {
"foo$BAR/baz.txt",
// ~ should not match mid-word
"foo~/bar.txt",
// double-slash comments are not paths
"// foo bar",
"//foo",
};
for (no_match_cases) |input| {
var result = re.search(input, .{});