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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 catch (e) | 106 catch (e) |
107 { | 107 { |
108 return false; | 108 return false; |
109 } | 109 } |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 /** | 113 /** |
114 * @typedef ParsedFilter | 114 * @typedef ParsedFilter |
115 * @property {?Filter} [filter] The parsed filter if it is valid. | 115 * @property {?Filter} [filter] |
116 * Or null if the given string is empty. | 116 * The parsed filter if it is valid. Or null if the given string is empty. |
117 * @property {FilterParsingError} [error] | 117 * @property {FilterParsingError} [error] |
118 * See {@link module:filterValidation~FilterParsingError FilterParsingError} | 118 * See {@link module:filterValidation~FilterParsingError FilterParsingError} |
119 */ | 119 */ |
120 | 120 |
121 let parseFilter = | 121 let parseFilter = |
122 /** | 122 /** |
123 * Parses and validates a filter given by the user. | 123 * Parses and validates a filter given by the user. |
124 * | 124 * |
125 * @param {string} text | 125 * @param {string} text |
126 * @return {ParsedFilter} | 126 * @return {ParsedFilter} |
127 */ | 127 */ |
128 exports.parseFilter = text => | 128 exports.parseFilter = text => |
(...skipping 18 matching lines...) Expand all Loading... |
147 return {error: new FilterParsingError("invalid-css-selector", | 147 return {error: new FilterParsingError("invalid-css-selector", |
148 {selector: filter.selector})}; | 148 {selector: filter.selector})}; |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 return {filter}; | 152 return {filter}; |
153 }; | 153 }; |
154 | 154 |
155 /** | 155 /** |
156 * @typedef ParsedFilters | 156 * @typedef ParsedFilters |
157 * @property {Filter[]} filters The parsed result without invalid filters. | 157 * @property {Filter[]} filters |
| 158 * The parsed result without invalid filters. |
158 * @property {FilterParsingError[]} errors | 159 * @property {FilterParsingError[]} errors |
159 * See {@link module:filterValidation~FilterParsingError FilterParsingError} | 160 * See {@link module:filterValidation~FilterParsingError FilterParsingError} |
160 */ | 161 */ |
161 | 162 |
162 /** | 163 /** |
163 * Parses and validates a newline-separated list of filters given by the user. | 164 * Parses and validates a newline-separated list of filters given by the user. |
164 * | 165 * |
165 * @param {string} text | 166 * @param {string} text |
166 * @return {ParsedFilters} | 167 * @return {ParsedFilters} |
167 */ | 168 */ |
168 exports.parseFilters = text => | 169 exports.parseFilters = text => |
169 { | 170 { |
(...skipping 10 matching lines...) Expand all Loading... |
180 | 181 |
181 if (error) | 182 if (error) |
182 { | 183 { |
183 error.lineno = i + 1; | 184 error.lineno = i + 1; |
184 errors.push(error); | 185 errors.push(error); |
185 } | 186 } |
186 } | 187 } |
187 | 188 |
188 return {filters, errors}; | 189 return {filters, errors}; |
189 }; | 190 }; |
LEFT | RIGHT |