mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-17 08:05:19 +00:00
22 lines
359 B
JavaScript
22 lines
359 B
JavaScript
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
|
|
};
|