File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
src/components/WebLogView/RequestDetails Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,11 @@ export function parseParams(data: ProxyData) {
3535 return stringify (
3636 // TODO: https://github.com/grafana/k6-studio/issues/277
3737 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
38- JSON . parse ( jsonrepair ( parsePythonByteString ( contentDecoded ) ) )
38+ JSON . parse (
39+ jsonrepair (
40+ parsePythonByteString ( wrapTemplateExpressionsInQuotes ( contentDecoded ) )
41+ )
42+ )
3943 )
4044 } catch ( e ) {
4145 console . error ( 'Failed to parse query parameters' , e )
@@ -64,3 +68,12 @@ export function isJsonString(str: string) {
6468export function getRawContent ( content : string ) {
6569 return content . replace ( / \s + / g, '' )
6670}
71+
72+ // When replacing number values in the payload, we need to wrap variable expressions
73+ // in quotes, otherwise JSON parse will fail
74+ function wrapTemplateExpressionsInQuotes ( str : string ) {
75+ return str . replace (
76+ / ( : \s * ) ( \$ \{ [ ^ } ] + \} ) (? = [ , } ] ) / g,
77+ ( _ , prefix , expr ) => `${ prefix } "${ expr } "`
78+ )
79+ }
You can’t perform that action at this time.
0 commit comments