Skip to content

Commit

Permalink
Fix noCompatMode flag for base60
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Dec 11, 2020
1 parent a003121 commit dc44dd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dumper.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,10 @@ function writeScalar(state, string, level, iskey) {
if (string.length === 0) {
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
}
if (!state.noCompatMode &&
DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 ||
DEPRECATED_BASE60_SYNTAX.test(string)) {
return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'");
if (!state.noCompatMode) {
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'");
}
}

var indent = state.indent * Math.max(1, level); // no 0-indent scalars
Expand Down
8 changes: 8 additions & 0 deletions test/issues/0027.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ describe('Should dump numbers in YAML 1.2 format', function () {
assert.strictEqual(yaml.dump(sample, { noCompatMode: false }), "'" + sample + "'\n");
});
});

it('should not quote base60 in noCompatMode', function () {
var tests = '1:23 1:23.45';

tests.split(' ').forEach(function (sample) {
assert.strictEqual(yaml.dump(sample, { noCompatMode: true }), sample + '\n');
});
});
});

0 comments on commit dc44dd3

Please sign in to comment.