Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/notification.js

Issue 29339343: Noissue - Removed redundant URL compatibility logic (Closed)
Left Patch Set: Created April 4, 2016, 11:16 a.m.
Right Patch Set: Use hostname Created April 4, 2016, 2:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/synchronizer.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (shown instanceof Array && shown.indexOf(notification.id) != -1) 212 if (shown instanceof Array && shown.indexOf(notification.id) != -1)
213 continue; 213 continue;
214 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) 214 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1)
215 continue; 215 continue;
216 } 216 }
217 217
218 if (typeof url === "string" || notification.urlFilters instanceof Array) 218 if (typeof url === "string" || notification.urlFilters instanceof Array)
219 { 219 {
220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array) 220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array)
221 { 221 {
222 let uri = Utils.makeURI(url); 222 let host;
Sebastian Noack 2016/04/04 11:19:46 Utils.makeURI() wraps Services.io.newURI() and ret
Wladimir Palant 2016/04/04 12:57:36 Actually, it is better to use `new URL` unconditio
Sebastian Noack 2016/04/04 13:40:38 Awesome. New patch set is up.
223 let host = uri && uri.host || ""; 223 try
224 {
225 host = new URL(url).hostname;
Sebastian Noack 2016/04/04 14:05:39 Sorry, I missed that. Before we used the hostname
226 }
227 catch (e)
228 {
229 host = "";
230 }
224 231
225 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO CUMENT, host, false, null); 232 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO CUMENT, host, false, null);
226 if (exception instanceof WhitelistFilter) 233 if (exception instanceof WhitelistFilter)
227 continue; 234 continue;
228 235
229 let matcher = new Matcher(); 236 let matcher = new Matcher();
230 for (let urlFilter of notification.urlFilters) 237 for (let urlFilter of notification.urlFilters)
231 matcher.add(Filter.fromText(urlFilter)); 238 matcher.add(Filter.fromText(urlFilter));
232 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals e, null)) 239 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals e, null))
233 continue; 240 continue;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 Prefs.notifications_showui = true; 398 Prefs.notifications_showui = true;
392 } 399 }
393 else if (index != -1 && forceValue !== true) 400 else if (index != -1 && forceValue !== true)
394 categories.splice(index, 1); 401 categories.splice(index, 1);
395 402
396 // HACK: JSON values aren't saved unless they are assigned a different objec t. 403 // HACK: JSON values aren't saved unless they are assigned a different objec t.
397 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories )); 404 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories ));
398 } 405 }
399 }; 406 };
400 Notification.init(); 407 Notification.init();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld