Skip to content

Commit

Permalink
Gatsby-link: Don't assume that __PREFIX_PATH__ is defined (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccormick authored and KyleAMathews committed Aug 1, 2017
1 parent 491fce8 commit 529acc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/gatsby-link/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const getNavigateTo = () => {
}

describe(`<Link />`, () => {

it(`does not fail to initialize when __PREFIX_PATHS__ is not defined`, () => {
expect(() => {
const Link = require(`../`).default
const link = new Link({}) //eslint-disable-line no-unused-vars
}).not.toThrow()
})

describe(`path prefixing`, () => {
it(`does not include path prefix by default`, () => {
const to = `/path`
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby-link/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*global __PREFIX_PATHS__, __PATH_PREFIX__ */
import React from "react"
import { Link, NavLink } from "react-router-dom"
import PropTypes from "prop-types"

let pathPrefix = ``
if (__PREFIX_PATHS__) {
if (typeof __PREFIX_PATHS__ !== `undefined` && __PREFIX_PATHS__) {
pathPrefix = __PATH_PREFIX__
}

Expand Down

0 comments on commit 529acc4

Please sign in to comment.