diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-11 22:12:07 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-11 22:12:07 +0100 |
commit | 756694c029218510592418deb8aaf6f3b36f95c3 (patch) | |
tree | 86d938cbf6360d46845758a7cc9575ca04aa3594 /lib/utils | |
parent | 669f3b39849890c48171d807225cd6eaa3c9086b (diff) | |
download | gitbook-756694c029218510592418deb8aaf6f3b36f95c3.zip gitbook-756694c029218510592418deb8aaf6f3b36f95c3.tar.gz gitbook-756694c029218510592418deb8aaf6f3b36f95c3.tar.bz2 |
Page output a simple html string
Diffstat (limited to 'lib/utils')
-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 }; |