page-spy-web icon indicating copy to clipboard operation
page-spy-web copied to clipboard

content-type 为 application/x-www-form-urlencoded,展示入参的时候格式化一下数据

Open zackxizi opened this issue 1 year ago • 0 comments

Description

目前展示的格式是: image 期望展示成: image

Suggested solution

将a=1&b=2的字符串转成 json

function queryStringToJSON(queryString) {
  // Split the query string into key-value pairs
  let pairs = queryString.split('&');
  let result = {};

  // Iterate over the pairs
  pairs.forEach(pair => {
    let [key, value] = pair.split('=');

    // Decode both key and value to handle URL encoding
    key = decodeURIComponent(key);
    value = decodeURIComponent(value || '');

    // Add key-value pair to result object
    result[key] = value;
  });

  return result;
}

Alternative

No response

Additional context

No response

Validations

zackxizi avatar Sep 27 '24 07:09 zackxizi