Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
try
{
host = Services.io.newURI(url, null, null).host;
}
catch (e)
{
// Ignore, an exception is expected for about: and similar schemes
host = "";
}
}
let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, false, null);
if (exception instanceof WhitelistFilter)
continue;
let matcher = new Matcher();
for (let urlFilter of notification.urlFilters)
matcher.add(Filter.fromText(urlFilter));
if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, false, null))
continue;
}
else
continue;
}
if (notification.targets instanceof Array)
{
let match = false;
for (let target of notification.targets)
{
if (checkTarget(target, "extension", addonName, addonVersion) &&
checkTarget(target, "application", application, applicationVersion) &&
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var Matcher = require('matcher').Matcher;
/**
* Provides smart matching suitable for 'quick open' functionality.
*/
exports.QuickMatcher = function(query) {
Matcher.call(this, query);
};
exports.QuickMatcher.prototype = new Matcher('subclassPrototype');
exports.QuickMatcher.prototype.score = function(query, item) {
query = query.toLowerCase();
var str = item.name.toLowerCase();
var path = item.path ? item.path.toLowerCase() : null;
// Name prefix match?
if (str.substring(0, query.length) === query) {
return 5000 - str.length;
}
// Path prefix match?
if (path && path.substring(0, query.length) === query) {
return 4000 - path.length;
}
if (notification.urlFilters instanceof Array)
{
let {url} = message;
if (!url)
return;
try
{
url = new URL(url);
}
catch (e)
{
return;
}
const matcher = new Matcher();
for (const urlFilter of notification.urlFilters)
{
matcher.add(Filter.fromText(urlFilter));
}
const {DOCUMENT} = RegExpFilter.typeMap;
if (!matcher.matchesAny(url, DOCUMENT, url.hostname))
return;
}
const texts = NotificationStorage.getLocalizedTexts(notification,
message.locale);
return Object.assign({texts}, notification);
});
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var Matcher = require('matcher').Matcher;
/**
* Performs simple prefix matching.
*/
exports.PrefixMatcher = function(query) {
Matcher.call(this, query);
};
exports.PrefixMatcher.prototype = new Matcher('subclassPrototype');
exports.PrefixMatcher.prototype.score = function(query, item) {
var queryLen = query.length;
if (queryLen > item.name.length) {
return 0;
}
if (item.name.substring(0, queryLen).toLowerCase() === query.toLowerCase()) {
return 1000 - item.name.length;
}
return 0;
};
if (notification.urlFilters instanceof Array)
{
let {url} = message;
if (!url)
return;
try
{
url = new URL(url);
}
catch (e)
{
return;
}
const matcher = new Matcher();
for (const urlFilter of notification.urlFilters)
{
matcher.add(Filter.fromText(urlFilter));
}
const {DOCUMENT} = RegExpFilter.typeMap;
if (!matcher.matchesAny(url, DOCUMENT, url.hostname))
return;
}
const texts = NotificationStorage.getLocalizedTexts(notification,
message.locale);
return Object.assign({texts}, notification);
});