<commit_before>angular.module("doubtfire.common.services.redirect", [])

.factory("redirectService", ($state, $stateParams) ->
  #
  # The redirect service object
  #
  redirectService = {}

  #TODO: need to test multiple params and nested objects here...
  deserialize = (str, prefix) ->
    result = {}
    parts = str.split "&"
    for i, attr of parts
      kv = attr.split "="
      k = kv[0]
      v = kv[1]
      result[k] = v
    result

  redirectService.redirect = (defaultState, defaultParams) ->
    destState = defaultState
    destParams = defaultParams
    if $stateParams["dest"] && $stateParams["dest"] isnt 'not_found'
      destState = $stateParams["dest"]
      destParams = deserialize $stateParams["params"] if $stateParams["params"]?
    $state.go destState, destParams

  redirectService
)<commit_msg>FIX: Prevent auth timeout cycle for unauthorised state<commit_after>angular.module("doubtfire.common.services.redirect", [])

.factory("redirectService", ($state, $stateParams) ->
  #
  # The redirect service object
  #
  redirectService = {}

  #TODO: need to test multiple params and nested objects here...
  deserialize = (str, prefix) ->
    result = {}
    parts = str.split "&"
    for i, attr of parts
      kv = attr.split "="
      k = kv[0]
      v = kv[1]
      result[k] = v
    result

  redirectService.redirect = (defaultState, defaultParams) ->
    destState = defaultState
    destParams = defaultParams
    if $stateParams["dest"] && !_.includes(['not_found', 'unauthorised'], $stateParams["dest"])
      destState = $stateParams["dest"]
      destParams = deserialize $stateParams["params"] if $stateParams["params"]?
    $state.go destState, destParams

  redirectService
)
{'fraction_non_alphanumeric': 0.13562281722933645, 'fraction_numerical': 0.002328288707799767, 'mean_word_length': 3.4190231362467864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7550499', 'n_tokens_mistral': 516, 'n_tokens_neox': 507, 'n_words': 131}