Repository: remix-run/react-router
File: packages/react-router-dom/__tests__/special-characters-test.tsx (TypeScript)

Code before:
 *   };
 * }
 */

let specialChars = [
  // This set of characters never gets encoded by window.location
  { char: "x", pathChar: "x", searchChar: "x", hashChar: "x", decodedChar: "x" },
  { char: "X", pathChar: "X", searchChar: "X", hashChar: "X", decodedChar: "X" },
  { char: "~", pathChar: "~", searchChar: "~", hashChar: "~", decodedChar: "~" },
  { char: "!", pathChar: "!", searchChar: "!", hashChar: "!", decodedChar: "!" },
  { char: "@", pathChar: "@", searchChar: "@", hashChar: "@", decodedChar: "@" },
  { char: "$", pathChar: "$", searchChar: "$", hashChar: "$", decodedChar: "$" },
  { char: "*", pathChar: "*", searchChar: "*", hashChar: "*", decodedChar: "*" },
  { char: "(", pathChar: "(", searchChar: "(", hashChar: "(", decodedChar: "(" },
  { char: ")", pathChar: ")", searchChar: ")", hashChar: ")", decodedChar: ")" },
  { char: "_", pathChar: "_", searchChar: "_", hashChar: "_", decodedChar: "_" },
  { char: "-", pathChar: "-", searchChar: "-", hashChar: "-", decodedChar: "-" },
  { char: "+", pathChar: "+", searchChar: "+", hashChar: "+", decodedChar: "+" },
  { char: "=", pathChar: "=", searchChar: "=", hashChar: "=", decodedChar: "=" },
  { char: "[", pathChar: "[", searchChar: "[", hashChar: "[", decodedChar: "[" },
  { char: "]", pathChar: "]", searchChar: "]", hashChar: "]", decodedChar: "]" },
  { char: ":", pathChar: ":", searchChar: ":", hashChar: ":", decodedChar: ":" },
  { char: ";", pathChar: ";", searchChar: ";", hashChar: ";", decodedChar: ";" },
  { char: ",", pathChar: ",", searchChar: ",", hashChar: ",", decodedChar: "," },

  // These chars should only get encoded when in the pathname, but JSDOM
  // seems to have a bug as it does not encode them, so don't test this
  // case for now
  // { char: "^", pathChar: "%5E", searchChar: "^", hashChar: "^" },
  // { char: "|", pathChar: "%7C", searchChar: "|", hashChar: "|" },

  // These chars get conditionally encoded based on what portion of the
  // URL they occur in
  { char: "{", pathChar: "%7B", searchChar: "{", hashChar: "{", decodedChar: "{" },
  { char: "}", pathChar: "%7D", searchChar: "}", hashChar: "}", decodedChar: "}" },
  { char: "`", pathChar: "%60", searchChar: "`", hashChar: "%60", decodedChar: "`" },
  { char: "'", pathChar: "'", searchChar: "%27", hashChar: "'", decodedChar: "'" },
  { char: '"', pathChar: "%22", searchChar: "%22", hashChar: "%22", decodedChar: '"' },
  { char: "<", pathChar: "%3C", searchChar: "%3C", hashChar: "%3C", decodedChar: "<" },
  { char: ">", pathChar: "%3E", searchChar: "%3E", hashChar: "%3E", decodedChar: ">" },

  // These chars get encoded in all portions of the URL
  {
    char: "🤯",
    pathChar: "%F0%9F%A4%AF",
    searchChar: "%F0%9F%A4%AF",
    hashChar: "%F0%9F%A4%AF",
    decodedChar: "🤯",
  },
  {
    char: "✅",

Review comment (suggestion):
Added the `decodedChar` to all existing setups - even though it's the same as the `char` since we now assert matched param values against `decodedChar`

Code after:
 *       hashChar: new URL('/#' + char, window.location.origin).hash.replace(/^#/, ''),
 *   };
 * }
 */

// prettier-ignore
let specialChars = [
  // This set of characters never gets encoded by window.location
  { char: "x", pathChar: "x", searchChar: "x", hashChar: "x", decodedChar: "x" },
  { char: "X", pathChar: "X", searchChar: "X", hashChar: "X", decodedChar: "X" },
  { char: "~", pathChar: "~", searchChar: "~", hashChar: "~", decodedChar: "~" },
  { char: "!", pathChar: "!", searchChar: "!", hashChar: "!", decodedChar: "!" },
  { char: "@", pathChar: "@", searchChar: "@", hashChar: "@", decodedChar: "@" },
  { char: "$", pathChar: "$", searchChar: "$", hashChar: "$", decodedChar: "$" },
  { char: "*", pathChar: "*", searchChar: "*", hashChar: "*", decodedChar: "*" },
  { char: "(", pathChar: "(", searchChar: "(", hashChar: "(", decodedChar: "(" },
  { char: ")", pathChar: ")", searchChar: ")", hashChar: ")", decodedChar: ")" },
  { char: "_", pathChar: "_", searchChar: "_", hashChar: "_", decodedChar: "_" },
  { char: "-", pathChar: "-", searchChar: "-", hashChar: "-", decodedChar: "-" },
  { char: "+", pathChar: "+", searchChar: "+", hashChar: "+", decodedChar: "+" },
  { char: "=", pathChar: "=", searchChar: "=", hashChar: "=", decodedChar: "=" },
  { char: "[", pathChar: "[", searchChar: "[", hashChar: "[", decodedChar: "[" },
  { char: "]", pathChar: "]", searchChar: "]", hashChar: "]", decodedChar: "]" },
  { char: ":", pathChar: ":", searchChar: ":", hashChar: ":", decodedChar: ":" },
  { char: ";", pathChar: ";", searchChar: ";", hashChar: ";", decodedChar: ";" },
  { char: ",", pathChar: ",", searchChar: ",", hashChar: ",", decodedChar: "," },

  // These chars should only get encoded when in the pathname, but JSDOM
  // seems to have a bug as it does not encode them, so don't test this
  // case for now
  // { char: "^", pathChar: "%5E", searchChar: "^", hashChar: "^" },
  // { char: "|", pathChar: "%7C", searchChar: "|", hashChar: "|" },

  // These chars get conditionally encoded based on what portion of the
  // URL they occur in
  { char: "{", pathChar: "%7B", searchChar: "{", hashChar: "{", decodedChar: "{" },
  { char: "}", pathChar: "%7D", searchChar: "}", hashChar: "}", decodedChar: "}" },
  { char: "`", pathChar: "%60", searchChar: "`", hashChar: "%60", decodedChar: "`" },
  { char: "'", pathChar: "'", searchChar: "%27", hashChar: "'", decodedChar: "'" },
  { char: '"', pathChar: "%22", searchChar: "%22", hashChar: "%22", decodedChar: '"' },
  { char: "<", pathChar: "%3C", searchChar: "%3C", hashChar: "%3C", decodedChar: "<" },
  { char: ">", pathChar: "%3E", searchChar: "%3E", hashChar: "%3E", decodedChar: ">" },

  // These chars get encoded in all portions of the URL
  { char: "🤯", pathChar: "%F0%9F%A4%AF", searchChar: "%F0%9F%A4%AF", hashChar: "%F0%9F%A4%AF", decodedChar: "🤯" },
  { char: "✅", pathChar: "%E2%9C%85", searchChar: "%E2%9C%85", hashChar: "%E2%9C%85", decodedChar: "✅" },
  { char: "🔥", pathChar: "%F0%9F%94%A5", searchChar: "%F0%9F%94%A5", hashChar: "%F0%9F%94%A5", decodedChar: "🔥" },
  { char: "ä", pathChar: "%C3%A4", searchChar: "%C3%A4", hashChar: "%C3%A4", decodedChar: "ä" },
  { char: "Ä", pathChar: "%C3%84", searchChar: "%C3%84", hashChar: "%C3%84", decodedChar: "Ä" },
  { char: "ø", pathChar: "%C3%B8", searchChar: "%C3%B8", hashChar: "%C3%B8", decodedChar: "ø" },
  { char: "山", pathChar: "%E5%B1%B1", searchChar: "%E5%B1%B1", hashChar: "%E5%B1%B1", decodedChar: "山" },