Skip to content

Commit

Permalink
fix: issue ndungtse#10 + v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ndungtse committed Dec 28, 2023
1 parent 8f68b72 commit 2d4ed85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions example/src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const NavBar = () => {
<button onClick={() => router.push('/button-link#34')}>ButtonLink</button>
<Link href={'#'}>HashLink</Link>
<Link href={'/contact/#44'}>HashLink1</Link>
<button onClick={() => router.replace('/about')}>Replace</button>
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next13-progressbar",
"version": "1.1.1",
"version": "1.1.2",
"description": "A ProgressBar for next.js >=13 with app directory ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -54,4 +54,4 @@
"dist/**/*.mjs*",
"dist/**/*.d*"
]
}
}
9 changes: 8 additions & 1 deletion src/AppProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,12 @@ export function useRouter() {
return router.push(href, options);
}

return { ...router, push };
function replace(href: string, options?: NavigateOptions) {
const targetUrl = new URL(href, location.href);
if (targetUrl.pathname === pathname) return Promise.resolve(true);
NProgress.start();
return router.replace(href, options);
}

return { ...router, push, replace };
}

0 comments on commit 2d4ed85

Please sign in to comment.