0

I am having a weird problem with Firefox on Angular and I dunno how to fix it or what to research in order to come up with a solution for it all URLs in Firefox are as follows:

http://www.domain.com/#somehash|%2FMerchant%2Fmerchant.com

the same URL in Chrome looks as follows:

http://www.domain.com/#somehash|/Merchant/merchant.com

this is proving to be problematic in Firefox because we are doing some conditional checking to the URL and this is causing some if conditions to fail for Firefox because of the encoding.

Thanks in advance.

Fouad
  • 855
  • 1
  • 11
  • 30

1 Answers1

0

You can use decodeURIComponent() to decode the url.

decodeURIComponent('http://www.domain.com/#somehash|%2FMerchant%2Fmerchant.com')
=> "http://www.domain.com/#somehash|/Merchant/merchant.com"

Keep in mind that the result might not be a valid URL.

For more details:

What is the difference between decodeURIComponent and decodeURI?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent

Community
  • 1
  • 1
XrXr
  • 2,027
  • 1
  • 14
  • 20
  • this is possible however i am wondering why the behavior is not consistent across different browsers – Fouad Dec 10 '14 at 17:32
  • How are you getting the URL? `document.URL` should be consistent across browsers – XrXr Dec 10 '14 at 17:41