<commit_before>(function () {
    'use strict';

    angular
        .module('dpDetail')
        .factory('endpointParser', endpointParserFactory);

    function endpointParserFactory () {
        return {
            getTemplateUrl,
            getGlossaryKey,
            getParts
        };

        function getTemplateUrl (endpoint) {
            const [category, subject] = getParts(endpoint);
            return `modules/detail/components/detail/templates/${category}/${subject}.html`;
        }

        function getGlossaryKey (endpoint) {
            const [, subject] = getParts(endpoint);
            return subject.toUpperCase().replace(/-/g, '_');
        }

        function getParts (endpoint) {
            const anchor = document.createElement('a');
            anchor.href = endpoint;

            // Transform http://www.api-root.com/this/that/123 to ['this', 'that', '123']
            const uriParts = anchor.pathname
                    .replace(/^\//, '') // Strip leading slash
                    .replace(/\/$/, '') // Strip trailing slash
                    .split('/');

            if (isZakelijkRecht(uriParts)) {
                return ['brk', 'subject'];
            } else if (isCatalogus(uriParts)) {
                return ['catalogus', 'api'];
            } else {
                // Remove the last segment (the ID)
                uriParts.pop();

                // Return the last two 'path' segments
                return uriParts.slice(-2);
            }

            function isZakelijkRecht (someUriParts) {
                return someUriParts[0] === 'brk' &&
                    someUriParts[1] === 'zakelijk-recht' &&
                    someUriParts[someUriParts.length - 1] === 'subject';
            }

            function isCatalogus (someUriParts) {
                return someUriParts[0] === 'catalogus' && someUriParts[1] === 'api';
            }
        }
    }
})();
<commit_msg>Grondexploitatie page title from API call<commit_after>(function () {
    'use strict';

    angular
        .module('dpDetail')
        .factory('endpointParser', endpointParserFactory);

    function endpointParserFactory () {
        return {
            getTemplateUrl,
            getGlossaryKey,
            getParts
        };

        function getTemplateUrl (endpoint) {
            const [category, subject] = getParts(endpoint);
            return `modules/detail/components/detail/templates/${category}/${subject}.html`;
        }

        function getGlossaryKey (endpoint) {
            const [type, subject] = getParts(endpoint);
            let key = subject;
            if (type === 'grondexploitatie') {
                key = type; // grondexploitatie subject === "project", 'grondexploitatie' is more descriptive value.
            }
            return key.toUpperCase().replace(/-/g, '_');
        }

        function getParts (endpoint) {
            const anchor = document.createElement('a');
            anchor.href = endpoint;

            // Transform http://www.api-root.com/this/that/123 to ['this', 'that', '123']
            const uriParts = anchor.pathname
                    .replace(/^\//, '') // Strip leading slash
                    .replace(/\/$/, '') // Strip trailing slash
                    .split('/');

            if (isZakelijkRecht(uriParts)) {
                return ['brk', 'subject'];
            } else if (isCatalogus(uriParts)) {
                return ['catalogus', 'api'];
            } else {
                // Remove the last segment (the ID)
                uriParts.pop();

                // Return the last two 'path' segments
                return uriParts.slice(-2);
            }

            function isZakelijkRecht (someUriParts) {
                return someUriParts[0] === 'brk' &&
                    someUriParts[1] === 'zakelijk-recht' &&
                    someUriParts[someUriParts.length - 1] === 'subject';
            }

            function isCatalogus (someUriParts) {
                return someUriParts[0] === 'catalogus' && someUriParts[1] === 'api';
            }
        }
    }
})();

{'fraction_non_alphanumeric': 0.13129102844638948, 'fraction_numerical': 0.005835156819839533, 'mean_word_length': 1.5521091811414391, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4555498', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1031, 'n_words': 226}