0

My url re-updating after the push I want to make this url:

www.abc.com/istanbul-taksim-otelleri?checkin=2019-05-08&checkout=2019-05-16&filters=meal_types:full,half,etc;stars:1,2,4 
const query = {
  checkin: '2019-05-08',
  checkout: '2019-05-16',
  filters:'meal_types:full,half,etc;stars:1,2,4'
}
 this.router.push({query}) 

after this gettin like this

www.abc.com/istanbul-taksim-otelleri?checkin=2019-05-08&checkout=2019-05-16&filters=meal_types%3Afull,half,etc%3Bstars%3A1,2,4

do you have any idea ? how can fix it ?

Adem yalçın
  • 176
  • 1
  • 6
  • Possible duplicate of [URIencode and colon](https://stackoverflow.com/questions/14872629/uriencode-and-colon) – Vucko Apr 16 '19 at 10:00

1 Answers1

0

See https://w3schools.com/tags/ref_urlencode.asp - %3A is just a URL-encoded colon. URL-encoding Strings is standard practice, and in most cases required in order to make a valid URL.

If you need to decode a URL, something like decodeURIComponent() could work for you, e.g.:

const uri = 'www.example.com/:";[]}'

const encodedURI = encodeURIComponent(uri)
console.log(encodedURI)

const decodedURI = decodeURIComponent(encodedURI)
console.log(decodedURI)
James Whiteley
  • 3,363
  • 1
  • 19
  • 46
  • unfortunately it's about vue-router, query is correct but after it's self-updating – Adem yalçın Apr 16 '19 at 13:31
  • Yeah I think that's just standard behaviour, not specific to Vue... Could you not decode the URL from whatever route you end up hitting? Browsers won't treat the URL any differently whether it's encoded or not (unless unencoded it makes it an invalid URL). – James Whiteley Apr 16 '19 at 14:04