diff options
Diffstat (limited to 'lib/utils/location.js')
-rw-r--r-- | lib/utils/location.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/utils/location.js b/lib/utils/location.js index d57e84f..efe1425 100644 --- a/lib/utils/location.js +++ b/lib/utils/location.js @@ -9,13 +9,23 @@ function isExternal(href) { } } - // Inverse of isExternal function isRelative(href) { return !isExternal(href); } +// Return true if the link is an achor +function isAnchor(href) { + try { + var parsed = url.parse(href); + return !!(!parsed.protocol && !parsed.path && parsed.hash); + } catch(err) { + return false; + } +} + module.exports = { isExternal: isExternal, - isRelative: isRelative + isRelative: isRelative, + isAnchor: isAnchor }; |