Route which contains character # will be improperly decoded, resulting in routing error
Closed this issue · 1 comments
brucou commented
Input URL:
http://localhost:3000/#/rdt/{"showUrl":{"state":{"error_message":"#div","target_language":"cze","first_language":"eng","user_id":1,"webpage_readable":"","url":"http://www.courrierinternational.com","showUrl.tooltip":{"state":{"word":"každodenní","ev":{"clientX":679,"clientY":195}}}}
Culprit are those lines in Router.prototype.init :
this.handler = function (onChangeEvent) {
var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash;
var url = self.history === true ? self.getPath() : newURL.replace(/.*#/, '');
self.dispatch('on', url.charAt(0) === '/' ? url : '/' + url);
};
The newURL.replace(/.*#/, '');
applied to the input URL matches up to #div
instead of matching up to the first # encountered
brucou commented
fixed as follows:
this.handler = function (onChangeEvent) {
var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash;
var url = self.history === true ? self.getPath() : newURL.replace(/.*?#/, '');
self.dispatch('on', url.charAt(0) === '/' ? url : '/' + url);
};