diff --git a/src/App.zig b/src/App.zig index 279c4e497..304072e42 100644 --- a/src/App.zig +++ b/src/App.zig @@ -580,4 +580,4 @@ pub const Wasm = if (!builtin.target.isWasm()) struct {} else struct { // alloc.destroy(v); // } // } -}; +}; \ No newline at end of file diff --git a/src/config/url.zig b/src/config/url.zig index 1d0764736..565691441 100644 --- a/src/config/url.zig +++ b/src/config/url.zig @@ -1,50 +1,64 @@ const std = @import("std"); const oni = @import("oniguruma"); -/// Default URL regex. This is used to detect URLs in terminal output. -/// This is here in the config package because one day the matchers will be -/// configurable and this will be a default. +/// Default URL regex. +/// +/// Sources: +/// 1. [Oniguruma GitHub](https://github.com/kkos/oniguruma) +/// 2. [Zig stdlib docs](https://ziglang.org/documentation/master/std/) /// -/// This regex is liberal in what it accepts after the scheme, with exceptions -/// for URLs ending with . or ). Although such URLs are perfectly valid, it is -/// common for text to contain URLs surrounded by parentheses (such as in -/// Markdown links) or at the end of sentences. Therefore, this regex excludes -/// them as follows: -/// -/// 1. Do not match regexes ending with . -/// 2. Do not match regexes ending with ), except for ones which contain a ( -/// without a subsequent ) -/// -/// Rule 2 means that that we handle the following two cases: -/// -/// "https://en.wikipedia.org/wiki/Rust_(video_game)" (include parens) -/// "(https://example.com)" (do not include the parens) -/// -/// There are many complicated cases where these heuristics break down, but -/// handling them well requires a non-regex approach. -pub const regex = - "(?:" ++ url_schemes ++ - \\)(?:[\w\-.~:/?#@!$&*+,;=%]+(?:[\(\[]\w*[\)\]])?)+(?