aboutsummaryrefslogtreecommitdiff
path: root/url-mode.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-02-03 12:56:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-02-05 12:35:17 +0000
commita984531ce57f30bc9ec7f664e7c2e8c77b3f439e (patch)
treec9533c6289d41e1b34e80bb003bf89ba6ffe4556 /url-mode.c
parentconfig: remove debug logging (diff)
url-mode: use the first *sub* expression as URL
When auto-matching URLs (or custom regular expressions), use the first *subexpression* as URL, rather than the while regex match. This allows us to write custom regular expressions with prefix/suffix strings that should not be included in the presented match.
Diffstat (limited to 'url-mode.c')
-rw-r--r--url-mode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/url-mode.c b/url-mode.c
index 3108ec12..0101de19 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -400,13 +400,13 @@ regex_detected(const struct terminal *term, enum url_action action,
if (r == REG_NOMATCH)
break;
- const size_t mlen = matches[0].rm_eo - matches[0].rm_so;
- const size_t start = &search_string[matches[0].rm_so] - v->utf8;
+ const size_t mlen = matches[1].rm_eo - matches[1].rm_so;
+ const size_t start = &search_string[matches[1].rm_so] - v->utf8;
const size_t end = start + mlen;
LOG_DBG(
"regex match at row %d: %.*srow/col = %dx%d",
- matches[0].rm_so, (int)mlen, &search_string[matches[0].rm_so],
+ matches[1].rm_so, (int)mlen, &search_string[matches[1].rm_so],
v->map[start].row, v->map[start].col);
tll_push_back(