summaryrefslogtreecommitdiff
path: root/urlmatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'urlmatch.c')
-rw-r--r--urlmatch.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/urlmatch.c b/urlmatch.c
index 3e42bd7504..33a2ccd306 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -557,6 +557,8 @@ int urlmatch_config_entry(const char *var, const char *value, void *cb)
const char *key, *dot;
struct strbuf synthkey = STRBUF_INIT;
int retval;
+ int (*select_fn)(const struct urlmatch_item *a, const struct urlmatch_item *b) =
+ collect->select_fn ? collect->select_fn : cmp_matches;
if (!skip_prefix(var, collect->section, &key) || *(key++) != '.') {
if (collect->cascade_fn)
@@ -570,10 +572,14 @@ int urlmatch_config_entry(const char *var, const char *value, void *cb)
config_url = xmemdupz(key, dot - key);
norm_url = url_normalize_1(config_url, &norm_info, 1);
+ if (norm_url)
+ retval = match_urls(url, &norm_info, &matched);
+ else if (collect->fallback_match_fn)
+ retval = collect->fallback_match_fn(config_url,
+ collect->cb);
+ else
+ retval = 0;
free(config_url);
- if (!norm_url)
- return 0;
- retval = match_urls(url, &norm_info, &matched);
free(norm_url);
if (!retval)
return 0;
@@ -587,7 +593,7 @@ int urlmatch_config_entry(const char *var, const char *value, void *cb)
if (!item->util) {
item->util = xcalloc(1, sizeof(matched));
} else {
- if (cmp_matches(&matched, item->util) < 0)
+ if (select_fn(&matched, item->util) < 0)
/*
* Our match is worse than the old one,
* we cannot use it.