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

Side by Side Diff: lib/synchronizer.js

Issue 29879940: Issue 6923 - Simplify parsing of metadata (Closed)
Patch Set: Created Sept. 13, 2018, 4:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/synchronizer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 let params = { 154 let params = {
155 redirect: null, 155 redirect: null,
156 homepage: null, 156 homepage: null,
157 title: null, 157 title: null,
158 version: null, 158 version: null,
159 expires: null 159 expires: null
160 }; 160 };
161 for (let i = 1; i < lines.length; i++) 161 for (let i = 1; i < lines.length; i++)
162 { 162 {
163 let match = /^\s*!\s*(?:(\w+)\s*:\s*(.*)|\S)/.exec(lines[i]); 163 let match = /^\s*!\s*([^:]*[^:\s])\s*:\s*(.*)/.exec(lines[i]);
164 if (!match) 164 if (!match)
165 break; 165 break;
166 166
167 if (typeof match[1] != "undefined") 167 let keyword = match[1].toLowerCase();
168 if (params.hasOwnProperty(keyword))
168 { 169 {
169 let keyword = match[1].toLowerCase(); 170 params[keyword] = match[2];
170 if (params.hasOwnProperty(keyword)) 171 lines.splice(i--, 1);
171 {
172 params[keyword] = match[2];
173 lines.splice(i--, 1);
174 }
175 } 172 }
176 } 173 }
177 174
178 if (params.redirect) 175 if (params.redirect)
179 return redirectCallback(params.redirect); 176 return redirectCallback(params.redirect);
180 177
181 // Handle redirects 178 // Handle redirects
182 let subscription = Subscription.fromURL(downloadable.redirectURL || 179 let subscription = Subscription.fromURL(downloadable.redirectURL ||
183 downloadable.url); 180 downloadable.url);
184 if (downloadable.redirectURL && 181 if (downloadable.redirectURL &&
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 338 }
342 339
343 /** 340 /**
344 * This object is responsible for downloading filter subscriptions whenever 341 * This object is responsible for downloading filter subscriptions whenever
345 * necessary. 342 * necessary.
346 * @type {Synchronizer} 343 * @type {Synchronizer}
347 */ 344 */
348 let synchronizer = new Synchronizer(); 345 let synchronizer = new Synchronizer();
349 346
350 exports.Synchronizer = synchronizer; 347 exports.Synchronizer = synchronizer;
OLDNEW
« no previous file with comments | « no previous file | test/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld