0

Hi i want to compress my url very similar to below shown Result

enter image description here

Here is above output link: https://jsbin.com/cayuhox/edit?html,css,js,output

My Problem is (i will be having most of the url as shown below, which not working with above generator):

  1. http://100.22.0.77:8888/nginx/assets?s={%22path%22:%22com://ANTARTICA%22,%22sort_by%22:0}&page=1&_=1595330210051

  2. http://100.22.0.77:8888/nginx/assets/folder_assets_counter?s={%22path%22:%22com%3A%2F%2FANTARTICA%22}&_=1595330210050

 http://100.22.0.77:8888/nginx/assets/folder_assets_counter?s={"path":"com://ANTARTICA", selectedIds:["randeaee2d0af83b5cb4f86e","94ea39dc5eba3b41945d","ca49d38872e8b3f94758","6741e5d08fd18c7a69b3"]}&_=1595330210050
  1. and even big url so on..

Expected Output: i need to generate as short output as this one woPCpXJvc2VzwqNyZWTCp3Zpb2xldHPCpGJsdWXCpmZydWnEkcKSwqVhcHDEjwI from above hash urls should not exceed 500 chars. i'm very much open to use any plugin or some of your tricky javascript code

Please help me thanks in advance!!

Learner
  • 61
  • 2
  • 21
  • 1
    Did you try using a library like https://github.com/pieroxy/lz-string and then compressing to b64? – Mihail Feraru Jul 21 '20 at 11:39
  • @MihailFeraru, no i did not check that, but definitely i will check that, thanks for the info – Learner Jul 21 '20 at 12:18
  • @MihailFeraru, actually i tried that but it is generating something like this `઀낖ೠҕୠ伨ᣀ΀鰊愉誀癐˧꤁턀` kind of characters , but i don't want that kind of characters rather i want something this kind `GJsdWXCpmZydWnEkcKSwqVhcHDEjwI` – Learner Jul 22 '20 at 06:55
  • Did you encode the output using base64? – Mihail Feraru Jul 22 '20 at 07:31
  • @MihailFeraru, tried it is giving error `btoa('઀낖ೠҕୠ伨ᣀ΀鰊愉誀癐˧꤁턀')` this error `Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range.` in both case either `atob()` or `btoa()` – Learner Jul 22 '20 at 07:40
  • You need to convert it to raw bytes. Your current string is in UTF-16. Take a look at https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings – Mihail Feraru Jul 22 '20 at 08:01

0 Answers0