1

I'm having a frustrating problem with bit.ly. In my webapp, I have a URL param that contains a URL-encoded array value. So basically its param=${encodeURIComponent(JSON.stringify(["one","two","three"]))} which is param=%5B%22one%22%2C%22two%22%2C%22three%22%5D

The problem is, when I shorten the URL with bit.ly, the URL it redirects to has that param val unencoded, so its

myWebsite.com?param=["one","two","three'], which breaks my app. Has anyone had experience with this, or does anyone have ideas on how to handle this?

1
  • Strange. I can only confirm this behaviour. The Location HTTP response header is URL decoded in this example. This leaves it up to the browser to URL encode the redirected request. Browsers (tested Firefox and Chrome) only encode the " (double quote) in your example URL (which would seem to break your app). I thought that maybe you could doubly encode the request, however, Bitly then doesn't decode the URL at all, so it hits your site doubly encoded (which may also break your app)! Are you using the Bitly API? – MrWhite Mar 5 '20 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.