Repository navigation
fix: do not let an empty colon value consume the next line - #1091
Open
saruk-vedant wants to merge 1 commit into
Open
saruk-vedant wants to merge 1 commit into
saruk-vedant wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A key written with a colon and nothing after it eats the next line, so the variable below it disappears. For example,
A:\nB=2parsed as{ A: 'B=2' }instead of{ A: '', B: '2' }, in both the classic parser andparseFast.In
lib/main.js, the classicLINEregex separator changed from:\s+?(which could swallow the line break) to:(?:[^\S\r\n]+?|(?=\r|\n|$)), so after a colon only same-line whitespace is consumed, and a line ending leaves an empty value while still letting a quoted value on the next line match. InparseFast, the colon branch now advances past only the colon when the next character is a line ending or the colon is the last character, instead of skipping the newline.Two stale expectations in
tests/test-parse-fast.js(from commit 048dd48, which encoded the oldA:\nfoogives{ A: 'foo' }behaviour) were updated, and a new testan empty colon value does not consume the next linewith 14 cases checked against both parsers was added.How to test
npm test(build, lint, type check, all tap tests): 1456 total, 1455 pass, 1 skip, 0 fail.tests/test-parse.js,tests/test-parse-fast.js,tests/test-parse-multiline.js): 1085 assertions, all pass.standardlint on the two changed files: clean.URL:http://xstill giving{}, non-breaking space after the colon, and a value with a trailing comment.Fixes #1090
Changelog
This repo generates
CHANGELOG.mdat release time via standard-version, and recent merged fix PRs add no changelog entry, so no changelog fragment is included.