<commit_before>/**
 * URL History Service
 *
 * @module nag
 * @ngservice urlHistory
 */
angular.module('nag.urlHistory', [])
.factory('urlHistory', [
  '$location',
  '$timeout',
  function($location, $timeout) {
    var lastUrls = [];

    return {
      /**
       * Adds the current url the the list of previously stored urls
       *
       * @method addCurrent
       * @chainable
       *
       * @returns {urlHistory} Instance of self
       */
      addCurrent: function() {
        lastUrls.push($location.url());

        //we only need to keep that last 2 urls
        while(lastUrls.length > 2) {
          lastUrls.shift();
        }

        return this;
      },

      /**
       * Replace the current history item with the last url that was recorded
       *
       * @method replace
       * @chainable
       *
       * @param {boolean} moveBackwards Whether or not to move back to the previous page when the replace it set
       *
       * @returns {urlHistory} Instance of self
       */
      replace: function(moveBackwards) {
        $location.path(lastUrls[0]);
        $location.replace();

        if(moveBackwards === true) {
          return this.goBack();
        }

        return this;
      },

      /**
       * Move the browser to the previous page
       *
       * @method goBack
       * @chainable
       *
       * @returns {urlHistory} Instance of self
       */
      goBack: function() {
        window.history.back();

        return this;
      },

      /**
       * Move the browser to a specific page while ensuring all history cleanup is properly performed by angular
       *
       * @method goTo
       *
       * @param {string} url Url to move browser to
       *
       * @returns {urlHistory} Instance of self
       */
      goTo: function(url) {
        //the $timeout ensures that the browser history is cleaned up
        $timeout(function(){location.href = url;}, 0);
      }
    };
  }
]);<commit_msg>Documentation update<commit_after>/**
 * URL History Service
 *
 * @module nag
 * @ngservice urlHistory
 */
angular.module('nag.urlHistory', [])
.factory('urlHistory', [
  '$location',
  '$timeout',
  function($location, $timeout) {
    var lastUrls = [];

    return {
      /**
       * Adds the current url the the list of previously stored urls
       *
       * @method addCurrent
       * @chainable
       *
       * @returns {urlHistory} Instance of self
       */
      addCurrent: function() {
        lastUrls.push($location.url());

        //we only need to keep that last 2 urls
        while(lastUrls.length > 2) {
          lastUrls.shift();
        }

        return this;
      },

      /**
       * Replace the current history item with the last url that was recorded
       *
       * @method replace
       * @chainable
       *
       * @param {boolean} moveBackwards Whether or not to move back to the previous page when the replace it set
       *
       * @returns {urlHistory} Instance of self
       */
      replace: function(moveBackwards) {
        $location.path(lastUrls[0]);
        $location.replace();

        //moving backwards is useful so if the urse then also hits the back button, they will go to the previous page as expected instead of the current page
        //appearing to reload
        if(moveBackwards === true) {
          return this.goBack();
        }

        return this;
      },

      /**
       * Move the browser to the previous page
       *
       * @method goBack
       * @chainable
       *
       * @returns {urlHistory} Instance of self
       */
      goBack: function() {
        window.history.back();

        return this;
      },

      /**
       * Move the browser to a specific page while ensuring all history cleanup is properly performed by angular
       *
       * @method goTo
       *
       * @param {string} url Url to move browser to
       *
       * @returns {urlHistory} Instance of self
       */
      goTo: function(url) {
        //the $timeout ensures that the browser history is cleaned up
        $timeout(function(){location.href = url;}, 0);
      }
    };
  }
]);
{'fraction_non_alphanumeric': 0.10535238556551223, 'fraction_numerical': 0.0019375151368370065, 'mean_word_length': 1.7924273157538877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2043621', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1118, 'n_words': 368}