Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/gatsby-link/src/is-local-link.js
Original file line number Diff line number Diff line change
@@ -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)
}