Merged in feat/sw-3230-move-link-to-design-system (pull request #2618)
feat(SW-3230): Move Link to design-system * Move Link to design-system * Remove comments Approved-by: Linus Flood
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import { useMemo } from "react"
|
||||
|
||||
export const useCheckIfExternalLink = (url: string) => {
|
||||
return useMemo(() => {
|
||||
if (typeof window !== "undefined" && url?.length) {
|
||||
try {
|
||||
const hostName = window.location.hostname
|
||||
const newURL = new URL(url)
|
||||
|
||||
const hostsMatch = hostName === newURL.hostname
|
||||
const langRouteRegex = /^\/[a-zA-Z]{2}\//
|
||||
|
||||
return !hostsMatch || !langRouteRegex.test(newURL.pathname)
|
||||
} catch {
|
||||
// Don't care. Expecting internal url (#, /my-pages/overview, etc)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
}, [url])
|
||||
}
|
||||
Reference in New Issue
Block a user