1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00
This commit is contained in:
gorhill 2016-05-03 08:22:48 -04:00
parent a8cf54c3a0
commit 47b3e26942

View File

@ -1,7 +1,7 @@
/*******************************************************************************
µBlock - a browser extension to block requests.
Copyright (C) 2014 Raymond Hill
uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -19,8 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/
/* global vAPI, µBlock */
/******************************************************************************/
(function(){
@ -55,6 +53,7 @@ var matchWhitelistDirective = function(url, hostname, directive) {
if ( directive.indexOf('*') === -1 ) {
return url === directive;
}
// TODO: Revisit implementation to avoid creating a regex each time.
// Regex escape code inspired from:
// "Is there a RegExp.escape function in Javascript?"
// http://stackoverflow.com/a/3561711
@ -177,7 +176,7 @@ var matchWhitelistDirective = function(url, hostname, directive) {
'#': []
};
var reInvalidHostname = /[^a-z0-9.\-\[\]:]/;
var reHostnameExtractor = /([a-z0-9\[][a-z0-9.\-:]*[a-z0-9\]])\/(?:[^\x00-\x20\/]|$)[^\x00-\x20]*$/;
var reHostnameExtractor = /([a-z0-9\[][a-z0-9.\-]*[a-z0-9\]])(?::[\d*]+)?\/(?:[^\x00-\x20\/]|$)[^\x00-\x20]*$/;
var lines = s.split(/[\n\r]+/);
var line, matches, key, directive;
for ( var i = 0; i < lines.length; i++ ) {