Fix query array parser for navidrome api
This commit is contained in:
parent
003fb26c60
commit
8d5c82b0c6
1 changed files with 15 additions and 1 deletions
|
@ -205,7 +205,21 @@ const parsePath = (fullPath: string) => {
|
||||||
const [path, params] = fullPath.split('?');
|
const [path, params] = fullPath.split('?');
|
||||||
|
|
||||||
const parsedParams = qs.parse(params);
|
const parsedParams = qs.parse(params);
|
||||||
const notNilParams = omitBy(parsedParams, (value) => value === 'undefined' || value === 'null');
|
|
||||||
|
// Convert indexed object to array
|
||||||
|
const newParams: Record<string, any> = {};
|
||||||
|
Object.keys(parsedParams).forEach((key) => {
|
||||||
|
const isIndexedArrayObject =
|
||||||
|
typeof parsedParams[key] === 'object' && Object.keys(parsedParams[key] || {}).includes('0');
|
||||||
|
|
||||||
|
if (!isIndexedArrayObject) {
|
||||||
|
newParams[key] = parsedParams[key];
|
||||||
|
} else {
|
||||||
|
newParams[key] = Object.values(parsedParams[key] || {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const notNilParams = omitBy(newParams, (value) => value === 'undefined' || value === 'null');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
params: notNilParams,
|
params: notNilParams,
|
||||||
|
|
Reference in a new issue