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

Function generateQueryString

src/recognizer/index.ts:647–674  ·  view source on GitHub ↗
(params: Params)

Source from the content-addressed store, hash-verified

645}
646
647export function generateQueryString(params: Params): string {
648 const pairs: string[] = [];
649 const keys: string[] = Object.keys(params);
650 keys.sort();
651 for (let i = 0; i < keys.length; i++) {
652 const key = keys[i];
653 const value = params[key];
654 if (value == null) {
655 continue;
656 }
657 let pair = encodeURIComponent(key);
658 if (isArray(value)) {
659 for (let j = 0; j < value.length; j++) {
660 const arrayPair = `${key}[]=${encodeURIComponent(value[j])}`;
661 pairs.push(arrayPair);
662 }
663 } else {
664 pair += `=${encodeURIComponent(value as string)}`;
665 pairs.push(pair);
666 }
667 }
668
669 if (pairs.length === 0) {
670 return "";
671 }
672
673 return `?${pairs.join("&")}`;
674}
675
676export function parseQueryString(queryString: string): QueryParams {
677 const pairs = queryString.split("&");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…