diff --git a/packages/gatsby-link/src/is-local-link.js b/packages/gatsby-link/src/is-local-link.js index b97c7a1915f5f..6ac72e3740332 100644 --- a/packages/gatsby-link/src/is-local-link.js +++ b/packages/gatsby-link/src/is-local-link.js @@ -1,13 +1,13 @@ -// Copied from https://github.com/sindresorhus/is-absolute-url/blob/3ab19cc2e599a03ea691bcb8a4c09fa3ebb5da4f/index.js -const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/ -const isAbsolute = path => ABSOLUTE_URL_REGEX.test(path) +const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\// -export const isLocalLink = path => { +function isAbsolute(path) { + return ABSOLUTE_URL_REGEX.test(path) +} + +export function isLocalLink(path) { if (typeof path !== `string`) { return undefined - // TODO(v5): Re-Add TypeError - // throw new TypeError(`Expected a \`string\`, got \`${typeof path}\``) } - + if (!path) return false return !isAbsolute(path) }