mmikowski/urianchor

Setting empty anchor map causes page to reload

Opened this issue · 0 comments

Lines 363-365 in jquery.uriAnchor.js:

uri_string = anchor_string
        ? uri_array[0] + '#!' + anchor_string : uri_array[0]
        ;

cause the page to be reloaded when the anchorMap passed in has all parameters removed, because line 378,

document.location.href = uri_string;

will then set document href to uri_array[0], which will not have a '#!'.

One fix would be to replace lines 363-365 with something like

uri_string = uri_array[0] + '#!' + (anchor_string ?  anchor_string : "");

which will leave the hashbang in the HREF even when anchor_string is falsy.