0

Tokens are generated from a third party service.
Sometimes these tokens include %2F like 0Tqn66huZhfX%2Fft7nPnCj1Id

I am writing a wrapper for this service and using spring rest.

When i send token with %2F in it to spring controller as @RequestParam it treats %2F as / character,

0Tqn66huZhfX%2Fft7nPnCj1Id becomes 0Tqn66huZhfX/ft7nPnCj1Id.

I must send this token to another server like below.

http://example.com/{token}/{otherVariable}

As spring gets %2F as /, it breaks the url format.

What can i do to get the token value with %2F without it being converted to /?

Salih Erikci
  • 5,076
  • 12
  • 39
  • 69

1 Answers1

-1

Browsers will encode the URL , based on character set used. we can prevent by using JS...etc,.

solution: before sending request encode that url using:

in JS: use encodeURI(url), This function encodes special characters, except: , / ? : @ & = + $ # for decode use: decodeURI(url)

  • ; , / ? : @ & = + $ are reserved characters in encodeURI and will not be encoded, as stated in the function's documentation: https://developer.mozilla.org/pt-PT/docs/Web/JavaScript/Reference/Global_Objects/encodeURI – Charles Sep 17 '19 at 13:04