mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fix issue with generating URLs.
This commit is contained in:
parent
912b63da82
commit
52bbc3692d
4 changed files with 15 additions and 16 deletions
|
|
@ -1,13 +1,11 @@
|
|||
import { useMemo } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
function getQueryString(params) {
|
||||
return new URLSearchParams({ ...params }).toString();
|
||||
}
|
||||
import { buildUrl } from 'next-basics';
|
||||
|
||||
export default function usePageQuery() {
|
||||
const router = useRouter();
|
||||
const { pathname, search } = location;
|
||||
const { asPath } = router;
|
||||
|
||||
const query = useMemo(() => {
|
||||
if (!search) {
|
||||
|
|
@ -26,11 +24,7 @@ export default function usePageQuery() {
|
|||
}, [search]);
|
||||
|
||||
function resolve(params) {
|
||||
const search = getQueryString({ ...query, ...params });
|
||||
|
||||
const { asPath } = router;
|
||||
|
||||
return `${asPath.split('?')[0]}${search}`;
|
||||
return buildUrl(asPath.split('?')[0], { ...query, ...params });
|
||||
}
|
||||
|
||||
return { pathname, query, resolve, router };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue