feat: Show icon on external links (#3100)
* feat: External links get treatment * cache decorations
This commit is contained in:
@@ -1,5 +1,30 @@
|
||||
import { parseDomain } from "./domains";
|
||||
|
||||
const env = typeof window !== "undefined" ? window.env : process.env;
|
||||
|
||||
export function cdnPath(path: string): string {
|
||||
return `${env.CDN_URL}${path}`;
|
||||
}
|
||||
|
||||
export function isInternalUrl(href: string) {
|
||||
if (href[0] === "/") {
|
||||
return true;
|
||||
}
|
||||
const outline =
|
||||
typeof window !== "undefined"
|
||||
? parseDomain(window.location.href)
|
||||
: undefined;
|
||||
const parsed = parseDomain(href);
|
||||
|
||||
if (
|
||||
parsed &&
|
||||
outline &&
|
||||
parsed.subdomain === outline.subdomain &&
|
||||
parsed.domain === outline.domain &&
|
||||
parsed.tld === outline.tld
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user