Merge pull request #157 from icanrealizeum/anchorsfixxage

Fixes #156 - anchors are now URI encoded
This commit is contained in:
Mathieu David 2016-07-31 14:31:32 +02:00 committed by GitHub
commit 9c8a563223
1 changed files with 3 additions and 1 deletions

View File

@ -57,7 +57,9 @@ $( document ).ready(function() {
var wrapper = $("<a class=\"header\">");
wrapper.attr("name", $(this).text());
// Add so that when you click the link actually shows up in the url bar...
wrapper.attr("href", $(location).attr('href') + "#" + $(this).text());
// Remove any existing anchor then append the new one
// ensuring eg. no spaces are present within it ie. they become %20
wrapper.attr("href", $(location).attr('href').split("#")[0] + "#" + encodeURIComponent($(this).text().trim()) );
return wrapper;
});