h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Support nested query or get raw query or both...

Open prpanto opened this issue 2 months ago • 0 comments

Describe the feature

I have a nested query like filter[color]=red&filter[size]=large&user[product][id]=385&sort=-createdAt&include=author,comments&active=true. I want to get the raw query to transform the query into object with qs lib or I would like to see this on the getQuery.

An example how I use qs lib:

const query = "?filter[color]=red&filter[size]=large&user[product][id]=385&sort=-createdAt&include=author,comments&active=true";
      
      const queryObject = qs.parse(query, {
        ignoreQueryPrefix: true,
        decoder: (str: string, defaultDecoder: qs.defaultDecoder, charset: string, type: "key" | "value") => {    
          if (type === "value" && !!Number(str)) {
            return Number(str);
          }

          if (type === "value" && str === "true") {
            return true;
          }
          
          if (type === "value" && str === "false") {
            return false;
          }

          if (type === "value" && str.includes(",")) {
            return str.split(",").map((s: string) => s.trim());
          }

          return defaultDecoder(str);
        }
      });

Edit: One way to get the raw query is: const rawQuery = getRequestURL(event).search; If I had the getRawQuery it will be better...

Additional information

  • [ ] Would you be willing to help implement this feature?

prpanto avatar Dec 05 '25 11:12 prpanto