<commit_before># URL encoding and decoding.
#
# url encode|decode <query> - URL encode or decode <string>

module.exports = (robot) ->
  robot.respond /URL encode( me)? (.*)/i, (msg) ->
    msg.send urlEncode(msg.match[2])

  robot.respond /URL decode( me)? (.*)/i, (msg) ->
    msg.send urlDecode(msg.match[2])

# url encoding helpers (shamelessly ripped from `jshashes` npm package)
urlEncode = (str) ->
  escape(str)
    .replace(new RegExp('\\+','g'),'%2B')
    .replace(new RegExp('%20','g'),'+')

urlDecode = (str) ->
  unescape(str.replace(new RegExp('\\+','g'), ' '))<commit_msg>Update url.coffee with a proper URL encoding/decoding<commit_after># URL encoding and decoding.
#
# url encode|decode <query> - URL encode or decode <string>
# url form encode|decode <query> - URL form-data encode or decode <string>

module.exports = (robot) ->
  robot.respond /URL encode( me)? (.*)/i, (msg) ->
    msg.send encodeURIComponent(msg.match[2])

  robot.respond /URL decode( me)? (.*)/i, (msg) ->
    msg.send decodeURIComponent(msg.match[2])

  robot.respond /URL form encode( me)? (.*)/i, (msg) ->
    msg.send urlFormEncode(msg.match[2])

  robot.respond /URL form decode( me)? (.*)/i, (msg) ->
    msg.send urlFormDecode(msg.match[2])

# url form-data encoding helpers (partially ripped from jshashes npm package)
urlFormEncode = (str) ->
  escape(str)
    .replace(new RegExp('\\+','g'),'%2B')
    .replace(new RegExp('%20','g'),'+')

urlFormDecode = (str) ->
  unescape(str.replace(new RegExp('\\+','g'), ' '))
{'fraction_non_alphanumeric': 0.2023731048121292, 'fraction_numerical': 0.007910349373764008, 'mean_word_length': 3.8810289389067525, 'pattern_counts': {'":': 0, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6474799', 'n_tokens_mistral': 552, 'n_tokens_neox': 546, 'n_words': 137}