<commit_before>// Copyright (c) CBC/Radio-Canada. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

define(['configs', 'lodash', 'router', 'array-utilities', 'string-utilities'],
    function(configs, _, router, arrayUtilities, stringUtitilies) {
        'use strict';

        var UrlUtilities = function UrlUtilities() {};

        UrlUtilities.prototype.url = function(url, baseUrl) {
            var baseUrl = (baseUrl || configs.baseUrl).replace(/^\/|\/$/g, '');
            url = url.replace(/^\//g, '');

            return '/' + baseUrl + '/' + url;
        };

        UrlUtilities.prototype.patternWithQueryString = function(url) {
            return this.url(url) + ':?queryString:';
        };

        UrlUtilities.prototype.getReturnUrl = function(_default) {
            var self = this;

            var context = router.context();
            var result =  self.url(_default);

            if (context && context.route.query.returnTo) {
                result = context.route.query.returnTo;
            }

            return result || '';
        };

        UrlUtilities.prototype.joinUrlParts = function () {
            var result = '';
            var urlParts = Array.prototype.slice.call(arguments, 0);

            if (arrayUtilities.isNotEmptyArray(urlParts)) {
                for (var i = 0; i < urlParts.length; i++) {
                    var urlPart = urlParts[i];
                    var isLast = i == (urlParts.length - 1);

                    if (urlPart && !isLast) {
                        urlPart = stringUtitilies.trimRight(urlPart, '/');
                        urlPart += '/';
                    }

                    result += urlPart;
                }
            }

            return result;
        };

        return new UrlUtilities();<commit_msg>added missing functions from merge<commit_after>// Copyright (c) CBC/Radio-Canada. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

define(['configs', 'lodash', 'router', 'array-utilities', 'string-utilities'],
    function(configs, _, router, arrayUtilities, stringUtitilies) {
        'use strict';

        var UrlUtilities = function UrlUtilities() {};

        UrlUtilities.prototype.isSameRelativeUrl = function(url1, url2) {
            return cleanUrl(url1) === cleanUrl(url2);
        };

        UrlUtilities.prototype.url = function(url, baseUrl) {
            baseUrl = (baseUrl || configs.baseUrl).replace(/^\/|\/$/g, '');
            url = url.replace(/^\//g, '');

            return '/' + baseUrl + '/' + url;
        };

        UrlUtilities.prototype.patternWithQueryString = function(url) {
            return this.url(url) + ':?queryString:';
        };

        UrlUtilities.prototype.getReturnUrl = function(_default) {
            var self = this;

            var context = router.context();
            var result =  self.url(_default);

            if (context && context.route.query.returnTo) {
                result = context.route.query.returnTo;
            }

            return result || '';
        };

        UrlUtilities.prototype.joinUrlParts = function () {
            var result = '';
            var urlParts = Array.prototype.slice.call(arguments, 0);

            if (arrayUtilities.isNotEmptyArray(urlParts)) {
                for (var i = 0; i < urlParts.length; i++) {
                    var urlPart = urlParts[i];
                    var isLast = i == (urlParts.length - 1);

                    if (urlPart && !isLast) {
                        urlPart = stringUtitilies.trimRight(urlPart, '/');
                        urlPart += '/';
                    }

                    result += urlPart;
                }
            }

            return result;
        };

        function cleanUrl(url){
            var result = url || '';
            result = result.replace(/#.*$/, '').replace(/^\/|\/$/g, '').toLowerCase();

            return result;
        }

        return new UrlUtilities();
{'fraction_non_alphanumeric': 0.13235653235653236, 'fraction_numerical': 0.002442002442002442, 'mean_word_length': 1.6580142764438677, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2445279', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1059, 'n_words': 241}