Skip to content

Commit d6983dd

Browse files
author
Vitaly Puzrin
authored
Fix issue #526: wrong quote position writing condensed flow (#527)
Fix issue #526: wrong quote position writing condensed flow
2 parents e569cc7 + 93fbf7d commit d6983dd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/js-yaml/dumper.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,12 @@ function writeFlowMapping(state, level, object) {
569569
pairBuffer;
570570

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

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

576+
if (state.condenseFlow) pairBuffer += '"';
577+
576578
objectKey = objectKeyList[index];
577579
objectValue = object[objectKey];
578580

test/issues/0346.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ test('should not emit spaces in arrays in flow mode between entries using conden
1515
});
1616

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

0 commit comments

Comments
 (0)