Fix URL params
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
6daa4672d2
commit
a20e57e062
1 changed files with 4 additions and 2 deletions
|
@ -10,9 +10,11 @@ const combineURLs = (baseURL: string, relativeURL: string) => relativeURL
|
|||
const buildFullPath = (requestedURL: string, baseURL?: string, params?: Record<string, any>) => {
|
||||
const path = (baseURL && !isAbsoluteURL(requestedURL)) ? combineURLs(baseURL, requestedURL) : requestedURL;
|
||||
|
||||
if (params) {
|
||||
return `${path}?${queryString.stringify(params, { arrayFormat: 'bracket' })}`;
|
||||
if (params && Object.entries(params).length) {
|
||||
const { url, query } = queryString.parseUrl(path);
|
||||
return `${url}?${queryString.stringify({ ...query, ...params }, { arrayFormat: 'bracket' })}`;
|
||||
}
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue