MCPcopy Create free account
hub / github.com/solidjs/solid-router / parseQueryString

Function parseQueryString

src/recognizer/index.ts:676–705  ·  view source on GitHub ↗
(queryString: string)

Source from the content-addressed store, hash-verified

674}
675
676export function parseQueryString(queryString: string): QueryParams {
677 const pairs = queryString.split("&");
678 const queryParams: QueryParams = {};
679 for (let i = 0; i < pairs.length; i++) {
680 const pair = pairs[i].split("=");
681 let key = decodeQueryParamPart(pair[0]);
682 const keyLength = key.length;
683 let isArray = false;
684 let value: string;
685 if (pair.length === 1) {
686 value = "true";
687 } else {
688 // Handle arrays
689 if (keyLength > 2 && key.endsWith("[]")) {
690 isArray = true;
691 key = key.slice(0, keyLength - 2);
692 if (!queryParams[key]) {
693 queryParams[key] = [];
694 }
695 }
696 value = pair[1] ? decodeQueryParamPart(pair[1]) : "";
697 }
698 if (isArray) {
699 (queryParams[key] as string[]).push(value);
700 } else {
701 queryParams[key] = value;
702 }
703 }
704 return queryParams;
705}
706
707interface CharSpec {
708 negate: boolean;

Callers 1

recognizeMethod · 0.85

Calls 1

decodeQueryParamPartFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…