mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Note serializer: Add yet another edge case
This commit is contained in:
@ -78,11 +78,16 @@ class MarkdownYAMLSerializer implements NoteSerializer {
|
||||
var yamlText = str.substring(4, endYamlPos);
|
||||
var map = _parseYamlText(yamlText);
|
||||
|
||||
var body = "";
|
||||
var bodyBeginingPos = endYamlPos + endYamlStr.length;
|
||||
if (bodyBeginingPos < str.length) {
|
||||
if (str[bodyBeginingPos] == '\n') {
|
||||
bodyBeginingPos += 1;
|
||||
}
|
||||
var body = str.substring(bodyBeginingPos);
|
||||
if (bodyBeginingPos < str.length) {
|
||||
body = str.substring(bodyBeginingPos);
|
||||
}
|
||||
}
|
||||
|
||||
return NoteData(body, map);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ Alright.""";
|
||||
expect(actualStr, note.body);
|
||||
});
|
||||
|
||||
test('Only YAML Header without \\n', () {
|
||||
test('Only YAML Header without \\n at end', () {
|
||||
var str = """---
|
||||
foo: bar
|
||||
---""";
|
||||
@ -166,5 +166,21 @@ foo: bar
|
||||
var actualStr = serializer.encode(note);
|
||||
expect(actualStr, str + '\n\n');
|
||||
});
|
||||
|
||||
test('Only YAML Header with \\n at end', () {
|
||||
var str = """---
|
||||
foo: bar
|
||||
---
|
||||
""";
|
||||
|
||||
var serializer = MarkdownYAMLSerializer();
|
||||
var note = serializer.decode(str);
|
||||
|
||||
expect("", note.body);
|
||||
expect({"foo": "bar"}, note.props);
|
||||
|
||||
var actualStr = serializer.encode(note);
|
||||
expect(actualStr, str + '\n');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user