handle empty comments correctly

since the lines in the parser have all newline characters removed, \s+ will
not match empty comments.

Added an example that makes other tests fail without this patch.
This commit is contained in:
Julian Bäume
2014-06-19 17:04:03 +02:00
parent eeb1382dfb
commit 08e7db58b3
3 changed files with 26 additions and 4 deletions

View File

@@ -146,9 +146,9 @@ PO.parse = function (data) {
for (var i = 0; i < flags.length; i++) {
item.flags[flags[i]] = true;
}
} else if (line.match(/^#\s+/)) { // Translator comment
} else if (line.match(/^#($|\s+)/)) { // Translator comment
finish();
item.comments.push(trim(line.replace(/^#\s+/, '')));
item.comments.push(trim(line.replace(/^#($|\s+)/, '')));
} else if (line.match(/^#\./)) { // Extracted comment
finish();
item.extractedComments.push(trim(line.replace(/^#\./, '')));