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

Side by Side Diff: lib/synchronizer.js

Issue 29873570: Issue 6923 - Only parse metadata from special comments at the top of the file (Closed)
Patch Set: Addressed comment about tests Created Sept. 10, 2018, 6:50 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return errorCallback("synchronize_invalid_data"); 151 return errorCallback("synchronize_invalid_data");
152 let minVersion = headerMatch[1]; 152 let minVersion = headerMatch[1];
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 = 0; i < lines.length; i++) 161 for (let i = 1; i < lines.length; i++)
162 { 162 {
163 let match = /^\s*!\s*(\w+)\s*:\s*(.*)/.exec(lines[i]); 163 let match = /^\s*!\s*(?:(\w+)\s*:\s*(.*)|\S)/.exec(lines[i]);
164 if (match) 164 if (!match)
165 break;
166
167 if (typeof match[1] != "undefined")
165 { 168 {
166 let keyword = match[1].toLowerCase(); 169 let keyword = match[1].toLowerCase();
167 let value = match[2]; 170 if (params.hasOwnProperty(keyword))
168 if (keyword in params)
169 { 171 {
170 params[keyword] = value; 172 params[keyword] = match[2];
171 lines.splice(i--, 1); 173 lines.splice(i--, 1);
172 } 174 }
173 } 175 }
174 } 176 }
175 177
176 if (params.redirect) 178 if (params.redirect)
177 return redirectCallback(params.redirect); 179 return redirectCallback(params.redirect);
178 180
179 // Handle redirects 181 // Handle redirects
180 let subscription = Subscription.fromURL(downloadable.redirectURL || 182 let subscription = Subscription.fromURL(downloadable.redirectURL ||
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 341 }
340 342
341 /** 343 /**
342 * This object is responsible for downloading filter subscriptions whenever 344 * This object is responsible for downloading filter subscriptions whenever
343 * necessary. 345 * necessary.
344 * @type {Synchronizer} 346 * @type {Synchronizer}
345 */ 347 */
346 let synchronizer = new Synchronizer(); 348 let synchronizer = new Synchronizer();
347 349
348 exports.Synchronizer = synchronizer; 350 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