Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -1055,21 +1055,20 @@ |
collapse = !inverse; |
break; |
case "sitekey": |
if (!value) |
return new InvalidFilter(origText, "filter_unknown_option"); |
sitekeys = value.toUpperCase(); |
break; |
case "rewrite": |
- if (value == null) |
- return new InvalidFilter(origText, "filter_unknown_option"); |
+ if (!value.startsWith("abp-resource:")) |
Manish Jethani
2019/04/15 21:26:37
`value` could still be `null`?
hub
2019/04/16 04:56:24
Yeah. I'll simplify this now that we are going the
|
+ return new InvalidFilter(origText, "filter_invalid_rewrite"); |
rewrite = value; |
- if (value.startsWith("abp-resource:")) |
- resourceName = value.substr("abp-resource:".length); |
+ resourceName = value.substr("abp-resource:".length); |
break; |
default: |
return new InvalidFilter(origText, "filter_unknown_option"); |
} |
} |
} |
} |
@@ -1223,26 +1222,16 @@ |
* @param {string} url the URL to rewrite |
* @return {string} the rewritten URL, or the original in case of failure |
*/ |
rewriteUrl(url) |
{ |
if (this.resourceName) |
return resourceMap.get(this.resourceName) || url; |
Manish Jethani
2019/04/15 21:26:37
If `resourceName` is `undefined` or `null` then I'
hub
2019/04/16 04:56:23
Done.
|
- try |
- { |
- let rewrittenUrl = new URL(url.replace(this.regexp, this.rewrite), url); |
- if (rewrittenUrl.origin == new URL(url).origin) |
- return rewrittenUrl.href; |
- } |
- catch (e) |
- { |
- } |
- |
return url; |
} |
}); |
/** |
* Class for whitelist filters |
* @param {string} text see {@link Filter Filter()} |
* @param {string} regexpSource see {@link RegExpFilter RegExpFilter()} |