Skip to content

Commit

Permalink
Added better detection for absolute urls in link component (#5286)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkwr authored Feb 7, 2023
1 parent 29ca7dc commit 336242a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
- lili21
- lionotm
- liranm
- lkwr
- lordofthecactus
- lpsinger
- lswest
Expand Down
6 changes: 2 additions & 4 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ function usePrefetchBehavior(
let NavLink = React.forwardRef<HTMLAnchorElement, RemixNavLinkProps>(
({ to, prefetch = "none", ...props }, forwardedRef) => {
let isAbsolute =
typeof to === "string" &&
(/^[a-z+]+:\/\//i.test(to) || to.startsWith("//"));
typeof to === "string" && /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(to);

let href = useHref(to);
let [shouldPrefetch, prefetchHandlers] = usePrefetchBehavior(
Expand Down Expand Up @@ -326,8 +325,7 @@ export { NavLink };
let Link = React.forwardRef<HTMLAnchorElement, RemixLinkProps>(
({ to, prefetch = "none", ...props }, forwardedRef) => {
let isAbsolute =
typeof to === "string" &&
(/^[a-z+]+:\/\//i.test(to) || to.startsWith("//"));
typeof to === "string" && /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(to);

let href = useHref(to);
let [shouldPrefetch, prefetchHandlers] = usePrefetchBehavior(
Expand Down

0 comments on commit 336242a

Please sign in to comment.