LEFT | RIGHT |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 798 |
799 /** | 799 /** |
800 * @see Matcher#matchesAny | 800 * @see Matcher#matchesAny |
801 * @inheritdoc | 801 * @inheritdoc |
802 */ | 802 */ |
803 matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) | 803 matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
804 { | 804 { |
805 let key = location + " " + typeMask + " " + docDomain + " " + thirdParty + | 805 let key = location + " " + typeMask + " " + docDomain + " " + thirdParty + |
806 " " + sitekey + " " + specificOnly; | 806 " " + sitekey + " " + specificOnly; |
807 | 807 |
808 let result = this._resultCache.read(key); | 808 let result = this._resultCache.get(key); |
809 if (typeof result != "undefined") | 809 if (typeof result != "undefined") |
810 return result; | 810 return result; |
811 | 811 |
812 result = this._matchesAnyInternal(location, typeMask, docDomain, | 812 result = this._matchesAnyInternal(location, typeMask, docDomain, |
813 thirdParty, sitekey, specificOnly); | 813 thirdParty, sitekey, specificOnly); |
814 | 814 |
815 this._resultCache.save(key, result); | 815 this._resultCache.set(key, result); |
816 | 816 |
817 return result; | 817 return result; |
818 } | 818 } |
819 | 819 |
820 /** | 820 /** |
821 * @typedef {object} MatcherSearchResults | 821 * @typedef {object} MatcherSearchResults |
822 * @property {Array.<BlockingFilter>} [blocking] List of blocking filters | 822 * @property {Array.<BlockingFilter>} [blocking] List of blocking filters |
823 * found. | 823 * found. |
824 * @property {Array.<WhitelistFilter>} [whitelist] List of whitelist filters | 824 * @property {Array.<WhitelistFilter>} [whitelist] List of whitelist filters |
825 * found. | 825 * found. |
(...skipping 15 matching lines...) Expand all Loading... |
841 * | 841 * |
842 * @returns {MatcherSearchResults} | 842 * @returns {MatcherSearchResults} |
843 */ | 843 */ |
844 search(location, typeMask, docDomain, thirdParty, sitekey, specificOnly, | 844 search(location, typeMask, docDomain, thirdParty, sitekey, specificOnly, |
845 filterType = "all") | 845 filterType = "all") |
846 { | 846 { |
847 let key = "* " + location + " " + typeMask + " " + docDomain + " " + | 847 let key = "* " + location + " " + typeMask + " " + docDomain + " " + |
848 thirdParty + " " + sitekey + " " + specificOnly + " " + | 848 thirdParty + " " + sitekey + " " + specificOnly + " " + |
849 filterType; | 849 filterType; |
850 | 850 |
851 let result = this._resultCache.read(key); | 851 let result = this._resultCache.get(key); |
852 if (typeof result != "undefined") | 852 if (typeof result != "undefined") |
853 return result; | 853 return result; |
854 | 854 |
855 result = this._searchInternal(location, typeMask, docDomain, thirdParty, | 855 result = this._searchInternal(location, typeMask, docDomain, thirdParty, |
856 sitekey, specificOnly, filterType); | 856 sitekey, specificOnly, filterType); |
857 | 857 |
858 this._resultCache.save(key, result); | 858 this._resultCache.set(key, result); |
859 | 859 |
860 return result; | 860 return result; |
861 } | 861 } |
862 | 862 |
863 /** | 863 /** |
864 * Tests whether the URL is whitelisted | 864 * Tests whether the URL is whitelisted |
865 * @see Matcher#matchesAny | 865 * @see Matcher#matchesAny |
866 * @inheritdoc | 866 * @inheritdoc |
867 * @returns {boolean} | 867 * @returns {boolean} |
868 */ | 868 */ |
869 isWhitelisted(location, typeMask, docDomain, thirdParty, sitekey) | 869 isWhitelisted(location, typeMask, docDomain, thirdParty, sitekey) |
870 { | 870 { |
871 return !!this._whitelist.matchesAny(location, typeMask, docDomain, | 871 return !!this._whitelist.matchesAny(location, typeMask, docDomain, |
872 thirdParty, sitekey); | 872 thirdParty, sitekey); |
873 } | 873 } |
874 } | 874 } |
875 | 875 |
876 exports.CombinedMatcher = CombinedMatcher; | 876 exports.CombinedMatcher = CombinedMatcher; |
877 | 877 |
878 /** | 878 /** |
879 * Shared {@link CombinedMatcher} instance that should usually be used. | 879 * Shared {@link CombinedMatcher} instance that should usually be used. |
880 * @type {CombinedMatcher} | 880 * @type {CombinedMatcher} |
881 */ | 881 */ |
882 let defaultMatcher = new CombinedMatcher(); | 882 let defaultMatcher = new CombinedMatcher(); |
883 | 883 |
884 exports.defaultMatcher = defaultMatcher; | 884 exports.defaultMatcher = defaultMatcher; |
LEFT | RIGHT |