Skip to content

Commit

Permalink
feat: skip if URL uses a non-http/https protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcru committed Dec 11, 2023
1 parent d483670 commit e26aed1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,16 @@ const HolyLoader = ({
anchor.target === "_blank" ||
event.ctrlKey ||
event.metaKey ||
anchor.href.startsWith("blob:")
// Skip if URL is a same-page anchor (href="#", href="#top", etc.).
isSamePageAnchor(window.location.href, anchor.href) ||
// Skip if URL uses a non-http/https protocol (mailto:, tel:, etc.).
!toAbsoluteURL(anchor.href).startsWith("http")
) {
return;
}

NProgress.start();
if (isSamePageAnchor(window.location.href, anchor.href)) {
NProgress.done();
document.documentElement.classList.remove("nprogress-busy");
} else {
overridePushState();
}
overridePushState();
} catch (error) {
NProgress.start();
NProgress.done();
Expand Down

0 comments on commit e26aed1

Please sign in to comment.