diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-05-20 15:58:06 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-05-22 12:50:47 +0000 |
| commit | 53516aceec01779cc62af134f11bd7d9be71fcba (patch) | |
| tree | 81b032a21ca8f7acc63e0949995e55da8473c8e1 /url-mode.c | |
| parent | config: move url-mode related options to a dedicated section, ‘url’ (diff) | |
config: add url.protocols
This makes the protocols recognized by auto-detected URLs
configurable.
Closes #531
Diffstat (limited to 'url-mode.c')
| -rw-r--r-- | url-mode.c | 24 |
1 files changed, 5 insertions, 19 deletions
@@ -212,23 +212,9 @@ static void auto_detected(const struct terminal *term, enum url_action action, url_list_t *urls) { - static const wchar_t *const prots[] = { - L"http://", - L"https://", - L"ftp://", - L"ftps://", - L"file://", - L"gemini://", - L"gopher://", - }; - - size_t max_prot_len = 0; - for (size_t i = 0; i < ALEN(prots); i++) { - size_t len = wcslen(prots[i]); - if (len > max_prot_len) - max_prot_len = len; - } + const struct config *conf = term->conf; + size_t max_prot_len = conf->url.max_prot_len; wchar_t proto_chars[max_prot_len]; struct coord proto_start[max_prot_len]; size_t proto_char_count = 0; @@ -266,15 +252,15 @@ auto_detected(const struct terminal *term, enum url_action action, proto_start[max_prot_len - 1] = (struct coord){c, r}; proto_char_count++; - for (size_t i = 0; i < ALEN(prots); i++) { - size_t prot_len = wcslen(prots[i]); + for (size_t i = 0; i < conf->url.prot_count; i++) { + size_t prot_len = wcslen(conf->url.protocols[i]); if (proto_char_count < prot_len) continue; const wchar_t *proto = &proto_chars[max_prot_len - prot_len]; - if (wcsncasecmp(prots[i], proto, prot_len) == 0) { + if (wcsncasecmp(conf->url.protocols[i], proto, prot_len) == 0) { state = STATE_URL; start = proto_start[max_prot_len - prot_len]; |
