diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-01-28 23:19:39 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-01-28 23:19:39 +0100 |
commit | ea98444dc0a6e59e79408963e1d340d7765ba9f6 (patch) | |
tree | ee946c4eebbe2a7cb9c8b572f2921dee859bbc8e /lib/utils | |
parent | 328c3a7d5141abdeab1488d6de8a47e62ebf48dc (diff) | |
download | gitbook-ea98444dc0a6e59e79408963e1d340d7765ba9f6.zip gitbook-ea98444dc0a6e59e79408963e1d340d7765ba9f6.tar.gz gitbook-ea98444dc0a6e59e79408963e1d340d7765ba9f6.tar.bz2 |
Add parsing of summary and tests
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/location.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/utils/location.js b/lib/utils/location.js new file mode 100644 index 0000000..d57e84f --- /dev/null +++ b/lib/utils/location.js @@ -0,0 +1,21 @@ +var url = require('url'); + +// Is the url an external url +function isExternal(href) { + try { + return Boolean(url.parse(href).protocol); + } catch(err) { + return false; + } +} + + +// Inverse of isExternal +function isRelative(href) { + return !isExternal(href); +} + +module.exports = { + isExternal: isExternal, + isRelative: isRelative +}; |