CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
1'use strict'2 3const { test } = require('tap')4const randomstring = require('randomstring')5const fastDecode = require('./index')6 7const charset = 'abcdef_ghilmn%opqrstu-vzxywjk%ABCDEF_HGILMN%OPQRSTU-VZXYWJK%0123456789.-_~%'8 9test('Basic', t => {10  // base test11  const uri = [12    'test', 'a+b+c+d', '=a', '%25', '%%25%%', 'st%C3%A5le', 'st%C3%A5le%', '%st%C3%A5le%', '%%7Bst%C3%A5le%7D%',13    '%ab%C3%A5le%', '%C3%A5%able%', '%7B%ab%7C%de%7D', '%7B%ab%%7C%de%%7D', '%7 B%ab%%7C%de%%7 D', '%61+%4d%4D',14    '\uFEFFtest', '\uFEFF', '%EF%BB%BFtest', '%EF%BB%BF', '†', '%C2%B5', '%C2%B5%', '%%C2%B5%', '%ab', '%ab%ab%ab',15    '%', '%2', '%E0%A4%A', '/test/hel%"Flo', '/test/hel%2Flo'16  ]17 18  // random generated uri19  for (var i = 0; i < 20000; i++) {20    uri.push(randomstring.generate({ charset }))21  }22 23  for (i = 0; i < uri.length; i++) {24    try {25      t.strictEqual(decodeURIComponent(uri[i]), fastDecode(uri[i]))26    } catch (e) {27      t.strictEqual(fastDecode(uri[i]), null)28    }29  }30 31  t.end()32})33