Skip to content

Commit

Permalink
fix: Use jsonrepair to parse potentially broken json payload (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
e-fisher authored Sep 17, 2024
1 parent 96bf2b4 commit 5124852
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"chokidar": "^3.6.0",
"electron-squirrel-startup": "^1.0.1",
"immer": "^10.1.1",
"jsonrepair": "^3.8.0",
"lodash-es": "^4.17.21",
"monaco-editor": "^0.50.0",
"node-forge": "^1.3.1",
Expand Down
5 changes: 4 additions & 1 deletion src/components/WebLogView/RequestDetails/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ProxyData } from '@/types'
import { safeAtob, stringify } from '@/utils/format'
import { getContentType } from '@/utils/headers'
import { jsonrepair } from 'jsonrepair'

export function parseParams(data: ProxyData) {
const hasParams = data.request.query.length || data.request.content
Expand All @@ -17,7 +18,9 @@ export function parseParams(data: ProxyData) {
}

return stringify(
JSON.parse(parsePythonByteString(safeAtob(data.request.content ?? '')))
JSON.parse(
jsonrepair(parsePythonByteString(safeAtob(data.request.content ?? '')))
)
)
} catch (e) {
console.error('Failed to parse query parameters', e)
Expand Down

0 comments on commit 5124852

Please sign in to comment.