mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #4916] [MERGED] feat: format JSON responses having text/plain content type #4987
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#4987
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/4916
Author: @anwarulislam
Created: 3/19/2025
Status: ✅ Merged
Merged: 3/28/2025
Merged by: @jamesgeorge007
Base:
next← Head:feat/json-for-text-plain📝 Commits (2)
21367fbfeat: add JSON validation for text/plain responses51e7396chore: keep JSON lens reserved for valid response body📊 Changes
2 files changed (+37 additions, -2 deletions)
View changed files
📝
packages/hoppscotch-common/src/helpers/lenses/jsonLens.ts(+26 -1)📝
packages/hoppscotch-common/src/helpers/lenses/lenses.ts(+11 -1)📄 Description
Closes HFE-791 #4239
This pull request introduces improvements to the JSON lens functionality in the
hoppscotch-commonpackage. The key changes include adding a utility function to validate JSON strings, updating the JSON lens to handletext/plaincontent types, and modifying the lens selection logic to prioritize the JSON lens for valid JSON content.Enhancements to JSON lens functionality:
packages/hoppscotch-common/src/helpers/lenses/jsonLens.ts: Added a new functionisValidJSONResponseto check if a string can be parsed as valid JSON.packages/hoppscotch-common/src/helpers/lenses/lenses.ts: Imported the newisValidJSONResponsefunction.What's changed
packages/hoppscotch-common/src/helpers/lenses/lenses.ts: Modified thegetSuitableLensesfunction to consider the JSON lens if the content type istext/plainand the response body contains valid JSON.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.