-
-
Notifications
You must be signed in to change notification settings - Fork 773
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
dumper: don't quote strings with # without need #521
Conversation
|
&& c !== CHAR_COLON | ||
&& c !== CHAR_SHARP; | ||
&& (c !== CHAR_SHARP || prev && isPrintable(prev)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
((c !== CHAR_SHARP) || (prev && isPrintable(prev)));
I'd use more scopes to simplify understanding.
Thanks for your review. You right, actually it is not a bug fix but proposition for more efficient usage of YAML specification. I've added some tests and made code more readable. |
Everything else seems ok. |
b5144b7
to
b09def6
Compare
b09def6
to
667b3a1
Compare
Thank you! |
@vcache, The test does not test anything. You should not parse the sample YAML if you are testing how it's dumped. I changed the test like this: test('Don\'t quote strings with # without need', function () {
var required = readFileSync(require('path').join(__dirname, '/0521.yml'), 'utf8');
var data = {
'http://example.com/page#anchor': 'no#quotes#required',
'parameter#fallback': 'quotes #required',
'foo #bar': 'key is quoted'
};
var actual = yaml.safeDump(data);
assert.equal(actual, required);
}); Now it fails. The |
According to spec a sharp symbol may be used within a key with plain style (i.e. without quotes) in certain conditions:
That's handy when key contains URI like so: