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

Unified Diff: lib/synchronizer.js

Issue 29873570: Issue 6923 - Only parse metadata from special comments at the top of the file (Closed)
Patch Set: Change end-of-metadata semantics Created Sept. 4, 2018, 8:14 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/synchronizer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/synchronizer.js
===================================================================
--- a/lib/synchronizer.js
+++ b/lib/synchronizer.js
@@ -160,16 +160,18 @@
version: null,
expires: null
};
- for (let i = 0; i < lines.length; i++)
+ for (let i = 1; i < lines.length; i++)
{
- let match = /^\s*!\s*(\w+)\s*:\s*(.*)/.exec(lines[i]);
- if (match)
+ let match = /^\s*!\s*(?:(\w+)\s*:\s*(.*)|\S)/.exec(lines[i]);
Manish Jethani 2018/09/05 18:10:08 How about this one: `/^\s*!\s*([^\s:]*)\s*(:)?\s*(
Sebastian Noack 2018/09/06 00:56:03 Done. Not sure if it's any easier to read through.
Manish Jethani 2018/09/06 05:53:53 I stand corrected, I meant `match[2]` A couple of
Sebastian Noack 2018/09/06 14:31:36 This is just a stop gap, what is eventually consid
Manish Jethani 2018/09/10 07:24:49 Acknowledged.
+ if (!match)
+ break;
+
+ if (match[1] != undefined)
Manish Jethani 2018/09/05 18:10:08 We never compare with `undefined` in core. `undefi
Sebastian Noack 2018/09/06 00:56:03 Actually, I cannot redefine undefined, neither thr
Manish Jethani 2018/09/06 05:53:53 You can just shadow `undefined` in the local scope
{
let keyword = match[1].toLowerCase();
- let value = match[2];
- if (keyword in params)
+ if (params.hasOwnProperty(keyword))
{
- params[keyword] = value;
+ params[keyword] = match[2];
lines.splice(i--, 1);
}
}
« 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