From 6f3a923691631912aadc2ccada757256de61a68f Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Wed, 4 Dec 2013 13:48:01 +0100 Subject: [PATCH] fixed urlmask which was not able to combine several constraints --- source/net/yacy/search/query/QueryParams.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.java index 3dbf38eb6..3455b026b 100644 --- a/source/net/yacy/search/query/QueryParams.java +++ b/source/net/yacy/search/query/QueryParams.java @@ -178,16 +178,13 @@ public final class QueryParams { } this.urlMask_isCatchall = this.urlMask.toString().equals(catchall_pattern.toString()); if (this.urlMask_isCatchall) { - if (modifier.protocol != null) { - this.urlMask = Pattern.compile(modifier.protocol + ".*"); - this.urlMask_isCatchall = false; - } - if (tld != null) { - this.urlMask = Pattern.compile(".*\\." + tld + ".*"); - this.urlMask_isCatchall = false; - } - if (modifier.filetype != null) { - this.urlMask = Pattern.compile(".*" + modifier.filetype + ".*"); + String protocolfilter = modifier.protocol == null ? ".*" : modifier.protocol; + String defaulthostprefix = modifier.protocol == null ? "www" : modifier.protocol; + String hostfilter = modifier.sitehost == null && tld == null ? ".*" : modifier.sitehost == null ? ".*\\." + tld : modifier.sitehost.startsWith(defaulthostprefix + ".") ? "(" + defaulthostprefix + "\\.)?" + modifier.sitehost.substring(4) : "(" + defaulthostprefix + "\\.)?" + modifier.sitehost; + String filefilter = modifier.filetype == null ? ".*" : ".*" + modifier.filetype + ".*"; + String filter = protocolfilter + "://" + hostfilter + "/" + filefilter; + if (!filter.equals(".*://.*/.*")) { + this.urlMask = Pattern.compile(filter); this.urlMask_isCatchall = false; } }