URI encoded hashtags in url, automatically decoded via PushState

I am trying to pull a url using a url encoded hashtag (I am creating a Twitter client). History.js seems to treat the encoded hashcodes (% 23) as encoded URIs in the url, so the url decodes them automatically, so it doesn't cause a state change with such links.

For example url / first /% 23second becomes / first / # second

What can I do without messing up the whole plugin?


source to share

1 answer

If you are hosting the History.js file locally, look inside for a function on an m object called "unescapeString" (or just Ctrl + F in "m.unescapeString".

Then you can change it to this:

    var c=b,d;

    if(!history.pushState){  //Adding this check.
        for(;;) {
            d = a.unescape(c);

            if (d===c) 

            c = d;
return c


This will fix the problem. (I believe this method is used to support browsers that do not support history.pushState)



All Articles