MCPcopy Create free account
hub / github.com/flatlogic/react-material-admin / parseRequestQuery

Function parseRequestQuery

src/repositories/usersMockRepository.js:190–219  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

188}
189
190function parseRequestQuery(request) {
191 const normalized = toTrimmedString(request)
192 .replace(/^(\?|&)+/, '')
193 .replace(/&+$/, '');
194
195 if (!normalized) {
196 return {};
197 }
198
199 const result = {};
200 const params = new URLSearchParams(normalized);
201
202 params.forEach((value, key) => {
203 const currentValue = result[key];
204
205 if (currentValue === undefined) {
206 result[key] = value;
207 return;
208 }
209
210 if (Array.isArray(currentValue)) {
211 result[key] = [...currentValue, value];
212 return;
213 }
214
215 result[key] = [currentValue, value];
216 });
217
218 return result;
219}
220
221function toComparableValue(value) {
222 if (value === null || value === undefined) {

Callers 1

listMockUsersFunction · 0.85

Calls 1

toTrimmedStringFunction · 0.85

Tested by

no test coverage detected