0

Backbone keeps decoding my query string params. For example when I do

var query_string = encodeURIComponent('New York')
Backbone.history.navigate('search?location='+query_string, {trigger: true})

I get an URL with path:

/#search?location=New York 

instead of

/#search?location=New%20York

I'm not using pushState and I've read that in 1.0.0 version he decodes the fragment in the URL. So any suggestions how can I achieve this, or something similar maybe?

Vlatko Ristovski
  • 111
  • 1
  • 11

1 Answers1

1

Unicode characters in location.pathname are percent encoded so they're decoded for comparison.

https://github.com/jashkenas/backbone/blob/master/backbone.js#L1587

You might have to fork the library and remove or modify decodeFragment method.

Miguel Mota
  • 20,135
  • 5
  • 45
  • 64