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: Created Sept. 3, 2018, 6:43 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,18 +160,17 @@
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*(\S.*?)\s*:\s*(.*)/.exec(lines[i]);
Sebastian Noack 2018/09/03 18:47:13 You might wonder why I changed this regular expres
Manish Jethani 2018/09/04 07:14:41 Acknowledged.
Sebastian Noack 2018/09/04 15:32:38 You have a point there. But in this regard, IMO we
+ if (!match)
+ break;
+
+ let keyword = match[1].toLowerCase();
+ if (keyword in params)
Manish Jethani 2018/09/04 07:14:41 BTW I find in my tests that `params.hasOwnProperty
Sebastian Noack 2018/09/04 14:22:06 IMO the in-operator reads much nicer, and this isn
Manish Jethani 2018/09/04 15:01:45 Acknowledged. (Aside from performance, it's also
{
- let keyword = match[1].toLowerCase();
- let value = match[2];
- if (keyword in params)
- {
- params[keyword] = value;
- lines.splice(i--, 1);
- }
+ params[keyword] = match[2];
+ lines.splice(i--, 1);
Manish Jethani 2018/09/04 07:14:41 Since we're considering malformed keywords as well
Sebastian Noack 2018/09/04 14:22:06 Historically, if it's not recognized as supported
Manish Jethani 2018/09/04 15:01:45 OK, fair enough. I'd like to consider not using `s
}
}
« 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