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

Simplify JSON trailing comment regular expression #11

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

mbland
Copy link
Owner

@mbland mbland commented Dec 30, 2023

Not a huge change, but when it comes to regular expressions, every bit of simplification helps—at least when it comes to readability, if not performance.

Not a huge change, but when it comes to regular expressions, every bit
of simplification helps—at least when it comes to readability, if not
performance.
@mbland mbland self-assigned this Dec 30, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7362319709

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 7362160098: 0.0%
Covered Lines: 248
Relevant Lines: 248

💛 - Coveralls

@mbland mbland merged commit 3f64019 into main Dec 30, 2023
3 checks passed
@mbland mbland deleted the simplify-json-trailing-comment-regex branch December 30, 2023 05:31
mbland added a commit that referenced this pull request Dec 30, 2023
I realized after merging #11 that the regular expression at the end of
stripJsonComments() would affect quoted strings. The new
"stripJsonComments > doesn't modify > strings including trailing commas"
test case confirmed this.

The new algorithm took a bit of trial and error, and the existing tests
really helped distill it to its essence. Quite happy with how it turned
out.

Also reorganized the test cases with more `describe` blocks. Added
the new "maintains correct syntax error position info when..." suite to
confirm positional info in JSON.parse errors remains correct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants