2

I am getting this url redirection from third party site http://localhost:4200/account/congratulations%3FdocumentId%3Dnnn

but i need to decode as http://localhost:4200/account/congratulations?documentId=nnn

for rendering my page '%3F' = '?' '%3D' = '=' where do i need to decode this in my project?

nkota
  • 555
  • 1
  • 6
  • 15
  • how do you get `http://localhost:4200/account/congratulations%3FdocumentId%3Dnnn` ? – Paul Mikki Jun 15 '19 at 08:24
  • i get this link from other site... actually this link is redirectin to my site from third party site – nkota Jun 15 '19 at 08:24
  • Where do you get this data from? Is it typed in by a user on a form? Is it a response from an http request you've executed on a service? Update your question with these kinds of details. Also, this URL you have only seems to be partially encoded (/ aren't encoded) which is also strange. – Dennis Jun 15 '19 at 08:25
  • It's not your app's fault. It is considered a broken link from another site – Paul Mikki Jun 15 '19 at 08:26
  • but i have to decode this url. from my app... pls suggest how to decode or url rewrite – nkota Jun 15 '19 at 08:28
  • @Dennis i just updated my question... pls check – nkota Jun 15 '19 at 08:31
  • If you can't make the third party site create a proper link, you'll have to create a new route in your application to be able to listen on that weird URL, extract information from the URL and then rebuild the URL properly and redirect your user to that new location. – Dennis Jun 15 '19 at 08:32
  • Usually, a redirected url will be decoded by the browser itself. either your decoded url is not as per the standards. – PankajH Jun 15 '19 at 08:33
  • @Dennis i can't make third party site to change url, how can i decode this url as proper link from our side – nkota Jun 15 '19 at 08:36
  • You can't decode it because that link is basically broken. If you want to solve it in your application you could use the approach I mentioned. But the best way is for that third party site to properly redirect to your site – Dennis Jun 15 '19 at 16:34

2 Answers2

2

You can use decodeURIComponent

Example :

decodeURIComponent("%3d")
Parth Ghiya
  • 6,929
  • 2
  • 30
  • 37
1

You can use decodeURI method in your service (the place where you're fetching that url )

decodeURI(url)
RajuPedda
  • 3,141
  • 3
  • 14
  • 27
  • i am not fetching that url... it's redirecting from other site after some operation completion in that third party site – nkota Jun 15 '19 at 08:34