mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5945] fix(jsonc): prevent blank lines from commented JSON fields #5426
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5426
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5945
Author: @sahilkhan09k
Created: 3/5/2026
Status: 🔄 Open
Base:
main← Head:fix-jsonc-comment-blank-lines📝 Commits (2)
0dd298bfix(jsonc): prevent blank lines from commented JSON fields1b8b3cdfix(jsonc): remove unused stripComments_ import📊 Changes
1 file changed (+2 additions, -2 deletions)
View changed files
📝
packages/hoppscotch-common/src/helpers/editor/linting/jsonc.ts(+2 -2)📄 Description
Closes #5629
This PR fixes an issue where commented lines in JSON request bodies generate extra blank lines in the final request sent over the wire, particularly visible in the desktop app.
The issue was caused by the
stripCommentshelper performing a redundant preprocessing step usingjsonc-parser.stripComments. This function replaces comment text with whitespace to preserve character offsets, which can leave whitespace-only lines in the processed body when fallback paths are triggered.Since
stripCommentsAndCommasalready parses JSONC usingjsonc-parser.parseTree(which natively ignores comments), the additional preprocessing step is unnecessary and can lead to malformed whitespace.What's changed
stripComments_preprocessing step instripComments.stripCommentsAndCommas.Notes to reviewers
stripCommentsAndCommasalready usesjsonc-parser.parseTree, which supports JSONC syntax including comments. Removing thestripComments_pre-pass simplifies the pipeline and avoids introducing whitespace padding from comment stripping.Tested with:
This ensures the final request body remains correctly formatted without extra blank lines.
Summary by cubic
Prevent extra blank lines in JSON request bodies when JSONC comments are used. stripComments now passes the original JSONC string to stripCommentsAndCommas, removing the redundant pre-pass that inserted whitespace-only lines and cleaning up the unused stripComments_ import.
Written for commit
1b8b3cd1e6. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.