davist11/jQuery-One-Page-Nav

fix: special characters like '/' or ':' or '.' in ID must be escaped for jQuery selector

Opened this issue · 1 comments

getHash: function($link) {
    var link_content = $link.attr('href').split('#')[1];
    link_content = link_content.replace( /([;&,\.\+\*\~':"\!\^\/#$%@\[\]\(\)=>\|])/g, "\\$1" );
    return link_content;
}

Oh and you need to remove the escape character ' \ ' before setting the new hash value:

//Do we need to change the hash?
newLoc = newLoc.replace( /(\\)/g, "" );
if(history.replaceState && self.config.changeHash) {
    history.replaceState(null, null, newLoc);
}
else {
    window.location.hash = newLoc;
}

in handleClick and handleScroll functions