<commit_before>/*jslint browser: true*/

(function () {
    'use strict';

    var departures = document.getElementById('departures');

    function getDeparturesCallback(response) {
        if (typeof response === 'string') {
            departures.outerHTML = response;
        }
    }

    if (departures) {
        reqwest(window.location.pathname + '/departures', getDeparturesCallback);
    }
})();<commit_msg>Make departures.js more tolerant of unexpected URLs<commit_after>/*jslint browser: true*/

(function () {
    'use strict';

    var departures = document.getElementById('departures');

    function getDeparturesURL() {
       var metaElements = document.getElementsByTagName('link');
       for (var i = metaElements.length - 1; i >= 0; i--) {
           if ('canonical' === metaElements[i].rel) {
               return metaElements[i].href + '/departures';
           }
       }
    }

    function getDeparturesCallback(response) {
        if (typeof response === 'string') {
            departures.outerHTML = response;
        }
    }

    if (departures) {
        reqwest(getDeparturesURL(), getDeparturesCallback);
    }
})();
{'fraction_non_alphanumeric': 0.13478260869565217, 'fraction_numerical': 0.0017391304347826088, 'mean_word_length': 2.6081504702194356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7127488', 'n_tokens_mistral': 340, 'n_tokens_neox': 330, 'n_words': 68}