Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #526: wrong quote position writing condensed flow #527

Merged
merged 1 commit into from Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/js-yaml/dumper.js
Expand Up @@ -569,10 +569,12 @@ function writeFlowMapping(state, level, object) {
pairBuffer;

for (index = 0, length = objectKeyList.length; index < length; index += 1) {
pairBuffer = state.condenseFlow ? '"' : '';

pairBuffer = '';
if (index !== 0) pairBuffer += ', ';

if (state.condenseFlow) pairBuffer += '"';

objectKey = objectKeyList[index];
objectValue = object[objectKey];

Expand Down
4 changes: 2 additions & 2 deletions test/issues/0346.js
Expand Up @@ -15,11 +15,11 @@ test('should not emit spaces in arrays in flow mode between entries using conden
});

test('should not emit spaces between key: value and quote keys using condenseFlow: true', function () {
var object = { a: { b: 'c' } };
var object = { a: { b: 'c', d: 'e' } };
var objectDump = yaml.dump(object, { flowLevel: 0, indent: 0, condenseFlow: true });
assert.equal(
objectDump,
'{"a":{"b":c}}\n'
'{"a":{"b":c, "d":e}}\n'
);
assert.deepEqual(yaml.load(objectDump), object);
});