<commit_before>define (require) ->
  Backbone = require('backbone')
  settings = require('settings')
  linksHelper = require('cs!helpers/links')
  session = require('cs!session')
  analytics = require('cs!helpers/handlers/analytics')
  AppView = require('cs!pages/app/app')

  return new class Router extends Backbone.Router
    initialize: () ->
      @appView = new AppView()

      # Default Route
      @route '*actions', 'default', () ->
        @appView.render('error', {code: 404})

      @route '', 'index', () ->
        @appView.render('home')

      @route 'workspace', 'workspace', () ->
        @appView.render('workspace')

      @route 'contents', 'contents', () ->
        @appView.render('contents')

      @route 'browse', 'browse', ->
        @appView.render('browse-content')

      @route 'tos', 'tos', () ->
        @appView.render('tos')

      @route 'license', 'license', () ->
        @appView.render('license')

      @route /^users\/role-acceptance\/(.+)/, 'role-acceptance', () ->
        @appView.render('role-acceptance')

      # Match and extract uuid and page numbers separated by a colon
      @route linksHelper.contentsLinkRegEx, 'media', (uuid, version, page, title, qs) ->
        # Downcase uuids, not short ids
        if uuid.length > 10
          uuid = uuid.toLowerCase()
        uuid = settings.shortcodes[uuid] if settings.shortcodes[uuid]
        pageId = if isNaN(page) then page else Number(page)
        @appView.render('contents', {uuid: uuid, version: version, page: pageId, qs: qs})

      @route /^donate\/?([^/\?;]*)?\/?([^/\?;]*)?\/?([^/\?;]*)?(?:\?)?.*/, 'donate', (page, uuid, type) ->
        @appView.render('donate', {page: page, uuid: uuid, type: type})

      @route /^(search)(?:\?q=)?(.*)/, 'search', () ->
        @appView.render('search')

      @route /^about\/?(.*)/, 'about', (page) ->
        @appView.render('about', {page: page})

    navigate: (fragment, options = {}, cb) ->
      super(arguments...)
      session.update() # Check for changes to the session status
      analytics.send() if options.analytics isnt false
      cb?()
      @trigger('navigate')
<commit_msg>Handle encoded URI symbols<commit_after>define (require) ->
  Backbone = require('backbone')
  settings = require('settings')
  linksHelper = require('cs!helpers/links')
  session = require('cs!session')
  analytics = require('cs!helpers/handlers/analytics')
  AppView = require('cs!pages/app/app')

  return new class Router extends Backbone.Router
    initialize: (args...) ->
      decodedPathname = decodeURIComponent(window.location.pathname)
      if (decodedPathname != window.location.pathname)
        window.location.pathname = decodedPathname
      @appView = new AppView()

      # Default Route
      @route '*actions', 'default', () ->
        @appView.render('error', {code: 404})

      @route '', 'index', () ->
        @appView.render('home')

      @route 'workspace', 'workspace', () ->
        @appView.render('workspace')

      @route 'contents', 'contents', () ->
        @appView.render('contents')

      @route 'browse', 'browse', ->
        @appView.render('browse-content')

      @route 'tos', 'tos', () ->
        @appView.render('tos')

      @route 'license', 'license', () ->
        @appView.render('license')

      @route /^users\/role-acceptance\/(.+)/, 'role-acceptance', () ->
        @appView.render('role-acceptance')

      # Match and extract uuid and page numbers separated by a colon
      @route linksHelper.contentsLinkRegEx, 'media', (uuid, version, page, title, qs) ->
        # Downcase uuids, not short ids
        if uuid.length > 10
          uuid = uuid.toLowerCase()
        uuid = settings.shortcodes[uuid] if settings.shortcodes[uuid]
        pageId = if isNaN(page) then page else Number(page)
        @appView.render('contents', {uuid: uuid, version: version, page: pageId, qs: qs})

      @route /^donate\/?([^/\?;]*)?\/?([^/\?;]*)?\/?([^/\?;]*)?(?:\?)?.*/, 'donate', (page, uuid, type) ->
        @appView.render('donate', {page: page, uuid: uuid, type: type})

      @route /^(search)(?:\?q=)?(.*)/, 'search', () ->
        @appView.render('search')

      @route /^about\/?(.*)/, 'about', (page) ->
        @appView.render('about', {page: page})

    navigate: (fragment, options = {}, cb) ->
      super(arguments...)
      session.update() # Check for changes to the session status
      analytics.send() if options.analytics isnt false
      cb?()
      @trigger('navigate')

{'fraction_non_alphanumeric': 0.1958119848518601, 'fraction_numerical': 0.0022276676319893073, 'mean_word_length': 2.808312128922816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '6687104', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1419, 'n_words': 315}