<commit_before>var url = require('url');
var path = require('path');

// Is the link an external link
var isExternal = function(href) {
    return Boolean(url.parse(href).protocol);
};

// Return true if the link is relative
var isRelative = function(href) {
    var parsed = url.parse(href);

    return !parsed.protocol && parsed.path && parsed.path[0] != '/';
};

// Relative to absolute path<commit_msg>Improve robustness of link utility functions<commit_after>var url = require('url');
var path = require('path');

// Is the link an external link
var isExternal = function(href) {
    try {
        return Boolean(url.parse(href).protocol);
    } catch(err) { }

    return false;
};

// Return true if the link is relative
var isRelative = function(href) {
    try {
        var parsed = url.parse(href);

        return !parsed.protocol && parsed.path && parsed.path[0] != '/';
    } catch(err) {}

    return true;
};

// Relative to absolute path
{'fraction_non_alphanumeric': 0.1424083769633508, 'fraction_numerical': 0.0020942408376963353, 'mean_word_length': 3.286995515695067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3348464', 'n_tokens_mistral': 286, 'n_tokens_neox': 279, 'n_words': 88}