зеркало из https://github.com/mozilla/ubiquity.git
Removed overquotings.
This commit is contained in:
Родитель
71c559619a
Коммит
81895dbcfe
|
@ -349,12 +349,11 @@ function onPageLoad(callback, includes, excludes) {
|
|||
var {pageLoadFuncs} = this.__globalObject;
|
||||
if (!includes && !excludes) return pageLoadFuncs.push(callback);
|
||||
|
||||
function enwild(a)
|
||||
Utils.regexp.quote(String(a).replace(/[*]/g, "\0")).replace(/\0/g, ".*?");
|
||||
[includes, excludes] = [includes || /^/, excludes].map(
|
||||
function toRegExps(filters) [
|
||||
Utils.classOf(f) === "RegExp" ? f : RegExp("^" + enwild(f) + "$")
|
||||
for each (f in [].concat(filters || []))]);
|
||||
function enwild(a) Utils.regexp.quote(a).replace(/\\[*]/g, ".*?");
|
||||
function toRegExps(filters) [
|
||||
Utils.classOf(f) === "RegExp" ? f : RegExp("^" + enwild(f) + "$")
|
||||
for each (f in [].concat(filters || []))];
|
||||
[includes, excludes] = [includes || /^/, excludes].map(toRegExps);
|
||||
return pageLoadFuncs.push(function pageLoadProxy(document) {
|
||||
var {href} = document.location;
|
||||
for each (let r in excludes) if (r.test(href)) return;
|
||||
|
|
|
@ -1303,7 +1303,7 @@ function regexp(pattern, flags) {
|
|||
// Returns the {{{string}}} with all regexp meta characters in it backslashed.
|
||||
|
||||
regexp.quote = function re_quote(string) (
|
||||
String(string).replace(/[.?*+^$|()\{\[\]\\]/g, "\\$&"));
|
||||
String(string).replace(/[.?*+^$|()\{\[\\]/g, "\\$&"));
|
||||
|
||||
// === {{{ Utils.regexp.Trie(strings, asPrefixes) }}} ===
|
||||
// Creates a {{{RegexpTrie}}} object that builds an efficient regexp
|
||||
|
|
|
@ -507,7 +507,7 @@ function testUtilsRegexp() {
|
|||
this.assertEquals(uneval(Utils.regexp("[")),
|
||||
uneval(/\[/));
|
||||
this.assertEquals(Utils.regexp.quote("[^.^]"),
|
||||
"\\[\\^\\.\\^\\]");
|
||||
"\\[\\^\\.\\^]");
|
||||
var words = ["foobar", "fooxar", "foozap", "fooza"]
|
||||
var re = Utils.regexp.Trie(words).toRegExp();
|
||||
for each (let word in words) this.assert(re.test(word), [re, word]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче