From 700cff70996625646bbb5054d83f7c36b48629b2 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 3 Jun 2020 12:41:05 +0100 Subject: [PATCH] fix(gatsby-link): Fail gracefully on empty `to` prop (#24745) Co-authored-by: gatsbybot --- packages/gatsby-link/src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-link/src/index.js b/packages/gatsby-link/src/index.js index 8a4c5bd0abf1d..052a3d98a85eb 100644 --- a/packages/gatsby-link/src/index.js +++ b/packages/gatsby-link/src/index.js @@ -7,7 +7,7 @@ import { parsePath } from "./parse-path" export { parsePath } -const isAbsolutePath = path => path.startsWith(`/`) +const isAbsolutePath = path => path?.startsWith(`/`) export function withPrefix(path, prefix = __BASE_PATH__) { if (!isLocalLink(path)) { @@ -25,6 +25,7 @@ export function withPrefix(path, prefix = __BASE_PATH__) { } const isLocalLink = path => + path && !path.startsWith(`http://`) && !path.startsWith(`https://`) && !path.startsWith(`//`)