1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 15:28:28 -04:00

compare origins of links instead of string comparison

This commit is contained in:
Jake Jarvis 2022-05-21 11:31:32 -04:00
parent 9b0adae9ed
commit 90a9512c62
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
4 changed files with 31 additions and 30 deletions

View File

@ -1,5 +1,6 @@
import NextLink from "next/link";
import { styled } from "../../lib/styles/stitches.config";
import { baseUrl } from "../../lib/config";
import type { ComponentProps } from "react";
import type { LinkProps as NextLinkProps } from "next/link";
@ -42,7 +43,7 @@ export type LinkProps = Omit<ComponentProps<typeof StyledLink>, "href"> &
const Link = ({ href, rel, target, prefetch = false, underline = true, openInNewTab, ...rest }: LinkProps) => {
// This component auto-detects whether or not this link should open in the same window (the default for internal
// links) or a new tab (the default for external links). Defaults can be overridden with `openInNewTab={true}`.
const isExternal = typeof href === "string" ? href.charAt(0) !== "/" && href.charAt(0) !== "#" : false;
const isExternal = typeof href === "string" ? new URL(href as string, baseUrl).origin !== baseUrl : false;
if (openInNewTab || isExternal) {
return (

View File

@ -12,7 +12,7 @@ module.exports = {
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: process.env.IS_DEV_SERVER
? "http://localhost:3000"
: "", // fallback to relative URLs
: "https://jarv.is", // fallback to production URL
onionDomain: "http://jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion",
shortDescription: "Front-End Web Developer in Boston, MA",
longDescription:

View File

@ -21,7 +21,7 @@
"@fontsource/comic-neue": "4.5.8",
"@fontsource/inter": "4.5.10",
"@fontsource/roboto-mono": "4.5.7",
"@giscus/react": "^2.0.4",
"@giscus/react": "^2.0.5",
"@hcaptcha/react-hcaptcha": "^1.3.0",
"@novnc/novnc": "github:novnc/noVNC#cdfb33665195eb9a73fb00feb6ebaccd1068cd50",
"@octokit/graphql": "^4.8.0",
@ -93,7 +93,7 @@
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"cross-env": "^7.0.3",
"eslint": "~8.15.0",
"eslint": "~8.16.0",
"eslint-config-next": "12.1.7-canary.10",
"eslint-config-prettier": "~8.5.0",
"eslint-plugin-mdx": "~1.17.0",

View File

@ -1033,15 +1033,15 @@
"@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0"
"@eslint/eslintrc@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.3.tgz#fcaa2bcef39e13d6e9e7f6271f4cc7cae1174886"
integrity sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==
"@eslint/eslintrc@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.0.tgz#29f92c30bb3e771e4a2048c95fa6855392dfac4f"
integrity sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==
dependencies:
ajv "^6.12.4"
debug "^4.3.2"
espree "^9.3.2"
globals "^13.9.0"
globals "^13.15.0"
ignore "^5.2.0"
import-fresh "^3.2.1"
js-yaml "^4.1.0"
@ -1063,12 +1063,12 @@
resolved "https://registry.yarnpkg.com/@fontsource/roboto-mono/-/roboto-mono-4.5.7.tgz#69a89b679ab962ea3591438f35833b09f0f8980f"
integrity sha512-1uBjM95BEz7zJlmmnpNAM5afMvIxx0wqr86eA76vRqZw8OF5wmsRqYfF3caHuVarBH9/AGN7t9h+3UXK8fjq/Q==
"@giscus/react@^2.0.4":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@giscus/react/-/react-2.0.4.tgz#9b2ae8cdd81ac7701bcc8bd48fad2a9ecb8956b2"
integrity sha512-gaASYFDV2ferpikuT3YqXB13MYD14eGOjY/dmxixqGtIfMAkJbmNr+qQ51E8kefCFcbExjhH0WI54/MmbY1dQQ==
"@giscus/react@^2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@giscus/react/-/react-2.0.5.tgz#70623df23618d1a4dcee4e9e076137cbd9843484"
integrity sha512-QTK4Buv+TqSJx9wovjANW130sFxnZ4/xtm2fEZifNSGaEVeT0AqfRM9Roe6n8OaJhBz5hZnlUpFWUZeHnTuu+A==
dependencies:
giscus "^1.0.3"
giscus "^1.0.5"
"@hcaptcha/react-hcaptcha@^1.3.0":
version "1.3.0"
@ -2897,12 +2897,12 @@ eslint-visitor-keys@^3.3.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==
eslint@~8.15.0:
version "8.15.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.15.0.tgz#fea1d55a7062da48d82600d2e0974c55612a11e9"
integrity sha512-GG5USZ1jhCu8HJkzGgeK8/+RGnHaNYZGrGDzUtigK3BsGESW/rs2az23XqE0WVwDxy1VRvvjSSGu5nB0Bu+6SA==
eslint@~8.16.0:
version "8.16.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.16.0.tgz#6d936e2d524599f2a86c708483b4c372c5d3bbae"
integrity sha512-MBndsoXY/PeVTDJeWsYj7kLZ5hQpJOfMYLsF6LicLHQWbRDG19lK5jOix4DPl8yY4SUFcE3txy86OzFLWT+yoA==
dependencies:
"@eslint/eslintrc" "^1.2.3"
"@eslint/eslintrc" "^1.3.0"
"@humanwhocodes/config-array" "^0.9.2"
ajv "^6.10.0"
chalk "^4.0.0"
@ -2920,7 +2920,7 @@ eslint@~8.15.0:
file-entry-cache "^6.0.1"
functional-red-black-tree "^1.0.1"
glob-parent "^6.0.1"
globals "^13.6.0"
globals "^13.15.0"
ignore "^5.2.0"
import-fresh "^3.0.0"
imurmurhash "^0.1.4"
@ -3255,12 +3255,12 @@ get-symbol-description@^1.0.0:
call-bind "^1.0.2"
get-intrinsic "^1.1.1"
giscus@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/giscus/-/giscus-1.0.4.tgz#8eabd976d721062d3f73ae5bf80fa92f776598dc"
integrity sha512-ebt3RwDDqcLi/4YuDJnDd8wTrILS+HdNkTmMzfgBNXnl18KWWXXMmY0R3W5n6tVOQU4nzVdxpaQV6Qlflz3KTA==
giscus@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/giscus/-/giscus-1.0.5.tgz#e526579bf1da6a394e23a8ac9f72a629825524d5"
integrity sha512-jg+4qUtyn2r9gCZJthbgPn/hLaoZAcZVhWx6d7+TYrrojMjAltrlSzYdsL++4iutVmGEYktp+nUJn2rQgZzvTg==
dependencies:
lit "^2.2.3"
lit "^2.2.4"
github-slugger@^1.1.1:
version "1.4.0"
@ -3310,7 +3310,7 @@ globals@^11.1.0:
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
globals@^13.6.0, globals@^13.9.0:
globals@^13.15.0:
version "13.15.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-13.15.0.tgz#38113218c907d2f7e98658af246cef8b77e90bac"
integrity sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==
@ -3951,7 +3951,7 @@ lit-html@^2.2.0:
dependencies:
"@types/trusted-types" "^2.0.2"
lit@^2.2.3:
lit@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/lit/-/lit-2.2.4.tgz#4907d071a427620b83653e39a1664dbdacbfb982"
integrity sha512-O7t+uizo1/Br0y+5RaWRzPkd4MsoL4XY2eq7n2wrESyCCjeagq4ERZKsyKX40jbmsz4bAAs7/0qNRX11TuXzoA==
@ -4705,9 +4705,9 @@ ms@^2.1.1:
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
nano-css@^5.3.1:
version "5.3.4"
resolved "https://registry.yarnpkg.com/nano-css/-/nano-css-5.3.4.tgz#40af6a83a76f84204f346e8ccaa9169cdae9167b"
integrity sha512-wfcviJB6NOxDIDfr7RFn/GlaN7I/Bhe4d39ZRCJ3xvZX60LVe2qZ+rDqM49nm4YT81gAjzS+ZklhKP/Gnfnubg==
version "5.3.5"
resolved "https://registry.yarnpkg.com/nano-css/-/nano-css-5.3.5.tgz#3075ea29ffdeb0c7cb6d25edb21d8f7fa8e8fe8e"
integrity sha512-vSB9X12bbNu4ALBu7nigJgRViZ6ja3OU7CeuiV1zMIbXOdmkLahgtPmh3GBOlDxbKY0CitqlPdOReGlBLSp+yg==
dependencies:
css-tree "^1.1.2"
csstype "^3.0.6"