mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
ignore lines w/o-newline delimiter @ link.regex
This commit is contained in:
@ -26,7 +26,7 @@ pub const regex =
|
|||||||
"(?:" ++ url_schemes ++
|
"(?:" ++ url_schemes ++
|
||||||
\\)(?:
|
\\)(?:
|
||||||
++ ipv6_url_pattern ++
|
++ ipv6_url_pattern ++
|
||||||
\\|[\w\-.~:/?#@!$&*+,;=%]+(?:[\(\[]\w*[\)\]])?)+(?<![,.])|(?:\.\.\/|\.\/*|\/)[\w\-.~:\/?#@!$&*+,;=%]+(?:\/[\w\-.~:\/?#@!$&*+,;=%]*)*
|
\\|[\w\-.~:/?#@!$&*+,;=%]+(?:[\(\[]\w*[\)\]])?)+(?<![,.%])|(?:\.\.\/|\.\/*|\/)[\w\-.~:\/?#@!$&*+,;=%]+(?:\/[\w\-.~:\/?#@!$&*+,;=%]*)*(?<!%)
|
||||||
;
|
;
|
||||||
const url_schemes =
|
const url_schemes =
|
||||||
\\https?://|mailto:|ftp://|file:|ssh:|git://|ssh://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:
|
\\https?://|mailto:|ftp://|file:|ssh:|git://|ssh://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:
|
||||||
@ -56,6 +56,10 @@ test "url regex" {
|
|||||||
expect: []const u8,
|
expect: []const u8,
|
||||||
num_matches: usize = 1,
|
num_matches: usize = 1,
|
||||||
}{
|
}{
|
||||||
|
.{
|
||||||
|
.input = "https://example.com%",
|
||||||
|
.expect = "https://example.com",
|
||||||
|
},
|
||||||
.{
|
.{
|
||||||
.input = "hello https://example.com world",
|
.input = "hello https://example.com world",
|
||||||
.expect = "https://example.com",
|
.expect = "https://example.com",
|
||||||
@ -117,6 +121,10 @@ test "url regex" {
|
|||||||
.input = "weird characters https://example.com/~user/?query=1&other=2#hash and more",
|
.input = "weird characters https://example.com/~user/?query=1&other=2#hash and more",
|
||||||
.expect = "https://example.com/~user/?query=1&other=2#hash",
|
.expect = "https://example.com/~user/?query=1&other=2#hash",
|
||||||
},
|
},
|
||||||
|
.{
|
||||||
|
.input = "https://example.com/?x=%59&y=X%",
|
||||||
|
.expect = "https://example.com/?x=%59&y=X",
|
||||||
|
},
|
||||||
// square brackets in URL
|
// square brackets in URL
|
||||||
.{
|
.{
|
||||||
.input = "square brackets https://example.com/[foo] and more",
|
.input = "square brackets https://example.com/[foo] and more",
|
||||||
@ -172,6 +180,10 @@ test "url regex" {
|
|||||||
.input = "match news:comp.infosystems.www.servers.unix news links",
|
.input = "match news:comp.infosystems.www.servers.unix news links",
|
||||||
.expect = "news:comp.infosystems.www.servers.unix",
|
.expect = "news:comp.infosystems.www.servers.unix",
|
||||||
},
|
},
|
||||||
|
.{
|
||||||
|
.input = "/Users/ghostty.user/code/example.py%",
|
||||||
|
.expect = "/Users/ghostty.user/code/example.py",
|
||||||
|
},
|
||||||
.{
|
.{
|
||||||
.input = "/Users/ghostty.user/code/example.py",
|
.input = "/Users/ghostty.user/code/example.py",
|
||||||
.expect = "/Users/ghostty.user/code/example.py",
|
.expect = "/Users/ghostty.user/code/example.py",
|
||||||
|
Reference in New Issue
Block a user