mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 18:56:08 +03:00
config/url: exclude trailing single quotes
This commit is contained in:
@ -26,7 +26,7 @@ const oni = @import("oniguruma");
|
|||||||
/// handling them well requires a non-regex approach.
|
/// handling them well requires a non-regex approach.
|
||||||
pub const regex = "(?:" ++ url_scheme ++ ")(?:[^" ++ url_exclude ++ "]*[^" ++ url_exclude ++ ").]|[^" ++ url_exclude ++ "(]*\\([^" ++ url_exclude ++ ")]*\\))";
|
pub const regex = "(?:" ++ url_scheme ++ ")(?:[^" ++ url_exclude ++ "]*[^" ++ url_exclude ++ ").]|[^" ++ url_exclude ++ "(]*\\([^" ++ url_exclude ++ ")]*\\))";
|
||||||
const url_scheme = "ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://";
|
const url_scheme = "ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://";
|
||||||
const url_exclude = "\u{0000}-\u{001F}\u{007F}-\u{009F}<>\x22\\s{-}\\^⟨⟩\x60";
|
const url_exclude = "\u{0000}-\u{001F}\u{007F}-\u{009F}<>\x22\x27\\s{-}\\^⟨⟩\x60";
|
||||||
|
|
||||||
test "url regex" {
|
test "url regex" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
@ -67,6 +67,14 @@ test "url regex" {
|
|||||||
.input = "Link period https://example.com. More text.",
|
.input = "Link period https://example.com. More text.",
|
||||||
.expect = "https://example.com",
|
.expect = "https://example.com",
|
||||||
},
|
},
|
||||||
|
.{
|
||||||
|
.input = "Link in double quotes \"https://example.com\" and more",
|
||||||
|
.expect = "https://example.com",
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.input = "Link in single quotes 'https://example.com' and more",
|
||||||
|
.expect = "https://example.com",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (cases) |case| {
|
for (cases) |case| {
|
||||||
|
Reference in New Issue
Block a user