Skip to content

Commit

Permalink
fix(gatsby-link): Fail gracefully on empty to prop (#24745)
Browse files Browse the repository at this point in the history
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
  • Loading branch information
ascorbic and gatsbybot committed Jun 3, 2020
1 parent 35d0dc6 commit 700cff7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/gatsby-link/src/index.js
Expand Up @@ -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)) {
Expand All @@ -25,6 +25,7 @@ export function withPrefix(path, prefix = __BASE_PATH__) {
}

const isLocalLink = path =>
path &&
!path.startsWith(`http://`) &&
!path.startsWith(`https://`) &&
!path.startsWith(`//`)
Expand Down

0 comments on commit 700cff7

Please sign in to comment.