jhudson8 / backbone-query-parameters

Backbone plugin which provides query parameter support
Other
388 stars 108 forks source link

Google URL Encoding #82

Open brandicted opened 10 years ago

brandicted commented 10 years ago

Hi,

I just came across an issue when working on making our search pages indexable by Google. We use backbone-query-parameters to render search-result pages.

The issue is that Googlebot always encodes the following characters found in URLs: " (space)", "<", ">", "[", "\", "]", "^", "`", "{", "|", "}". (read more here: http://www.monperrus.net/martin/google+url+encoding)

Since backbone-query-parameters uses "|" as separators, Google encodes those characters when crawling the URLs (i.e. %7C) and as a result backbone does not render the page as it should be.

I propose adding the following line 214 of backbone.queryparams.js: var value = Backbone.Router.decodeURISeparator?decodeURIComponent(value):value;

and add the Backbone.Router.decodeURISeparator mention to readme.md.

Let me know your thoughts.

thanks,

Jonathan

jhudson8 commented 10 years ago

I'll be looking at possibly removing the separator in future releases in favor of a more standard format (which is already supported); #myroute?foo=a|b is the same as #myroute?foo=a&foo=b