summaryrefslogtreecommitdiffstats
path: root/lib/utils/location.js
blob: d57e84fb4cca438ef2ac0e6a86cff4ac6883dc01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
};