<commit_before>Window =

  addSlash: (str) ->
    str.replace(/(?!\/)(.)$/, '$1/')

  getQueryParams: (qs) ->
    # http://stackoverflow.com/questions/439463
    qs = qs.split('+').join(' ')
    params = {}
    re = /[?&]?([^=]+)=([^&]*)/g
    while tokens = re.exec(qs)
      params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2])
    params

  currentURL: (_window) ->
    _window = _window || window
    window.location.protocol + '//' + window.location.host + window.location.pathname

  currentHost: (_window) ->
    _window = _window || window
    @addSlash(_window.location.protocol + '//' + _window.location.host)

  currentDir: ->
    @addSlash(@currentURL().substring(0, @currentURL().lastIndexOf('/')))

  GET: (key, _document) ->
    _document = _document || document
    GET = @getQueryParams(_document.location.search)
    if key then GET[key] else GET

  isEnabled: (name) ->
    setting = @GET(name)
    if setting != undefined then setting != '0' else true

  getVarBool: (name) ->
    variable = @GET(name)
    if variable == undefined then undefined else !!parseInt(variable)

  downloadFile: (url) -> location.href = url<commit_msg>Added check to ensure URL is provided when downloading files.<commit_after>Window =

  addSlash: (str) ->
    str.replace(/(?!\/)(.)$/, '$1/')

  getQueryParams: (qs) ->
    # http://stackoverflow.com/questions/439463
    qs = qs.split('+').join(' ')
    params = {}
    re = /[?&]?([^=]+)=([^&]*)/g
    while tokens = re.exec(qs)
      params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2])
    params

  currentURL: (_window) ->
    _window = _window || window
    window.location.protocol + '//' + window.location.host + window.location.pathname

  currentHost: (_window) ->
    _window = _window || window
    @addSlash(_window.location.protocol + '//' + _window.location.host)

  currentDir: ->
    @addSlash(@currentURL().substring(0, @currentURL().lastIndexOf('/')))

  GET: (key, _document) ->
    _document = _document || document
    GET = @getQueryParams(_document.location.search)
    if key then GET[key] else GET

  isEnabled: (name) ->
    setting = @GET(name)
    if setting != undefined then setting != '0' else true

  getVarBool: (name) ->
    variable = @GET(name)
    if variable == undefined then undefined else !!parseInt(variable)

  downloadFile: (url) ->
    unless url then return Logger.error('Could not download file - no URL provided')
    location.href = url
{'fraction_non_alphanumeric': 0.1744233104006475, 'fraction_numerical': 0.008903278025091057, 'mean_word_length': 3.3141361256544504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2924413', 'n_tokens_mistral': 818, 'n_tokens_neox': 790, 'n_words': 175}