MCPcopy Create free account
hub / github.com/ShaanCoding/makeread.me / getQueryString

Function getQueryString

frontend/openAPI/generated/core/request.ts:50–82  ·  view source on GitHub ↗
(params: Record<string, any>)

Source from the content-addressed store, hash-verified

48};
49
50export const getQueryString = (params: Record<string, any>): string => {
51 const qs: string[] = [];
52
53 const append = (key: string, value: any) => {
54 qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
55 };
56
57 const process = (key: string, value: any) => {
58 if (isDefined(value)) {
59 if (Array.isArray(value)) {
60 value.forEach(v => {
61 process(key, v);
62 });
63 } else if (typeof value === 'object') {
64 Object.entries(value).forEach(([k, v]) => {
65 process(`${key}[${k}]`, v);
66 });
67 } else {
68 append(key, value);
69 }
70 }
71 };
72
73 Object.entries(params).forEach(([key, value]) => {
74 process(key, value);
75 });
76
77 if (qs.length > 0) {
78 return `?${qs.join('&')}`;
79 }
80
81 return '';
82};
83
84const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
85 const encoder = config.ENCODE_PATH || encodeURI;

Callers 1

getUrlFunction · 0.85

Calls 1

processFunction · 0.85

Tested by

no test coverage detected