avoid escape characters by using a multiline string

lets concat url_scheme in combo with a multiline (thanks @qwerasd205)

regex: url_scheme -> url_schemes
This commit is contained in:
Erlend Lind Madsen
2024-08-28 22:29:57 +02:00
parent 19c9039494
commit e3881c4ffc

View File

@ -22,8 +22,13 @@ const oni = @import("oniguruma");
/// ///
/// There are many complicated cases where these heuristics break down, but /// There are many complicated cases where these heuristics break down, but
/// handling them well requires a non-regex approach. /// handling them well requires a non-regex approach.
pub const regex = "(?:" ++ url_scheme ++ ")(?:[\\w\\-.~:/?#\\[\\]@!$&*+,;=%]+(?:\\(\\w*\\))?)+(?<!\\.)"; pub const regex =
const url_scheme = "https?://|mailto:|ftp://|file:|ssh:|git://|ssh://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:"; "(?:" ++ url_schemes ++
\\)(?:[\w\-.~:/?#\[\]@!$&*+,;=%]+(?:\(\w*\))?)+(?<!\.)
;
const url_schemes =
\\https?://|mailto:|ftp://|file:|ssh:|git://|ssh://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:
;
test "url regex" { test "url regex" {
const testing = std.testing; const testing = std.testing;