Skip to content

Commit ce21c71

Browse files
committed
Fixed special characters bug
1 parent 31e7bc7 commit ce21c71

File tree

8 files changed

+64
-12
lines changed

8 files changed

+64
-12
lines changed

dist/smooth-scroll.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v16.1.0
2+
* smooth-scroll v16.1.1
33
* Animate scrolling to anchor links
44
* (c) 2019 Chris Ferdinandi
55
* MIT License
@@ -525,7 +525,13 @@
525525
if (toggle.hostname !== window.location.hostname || toggle.pathname !== window.location.pathname || !/#/.test(toggle.href)) return;
526526

527527
// Get an escaped version of the hash
528-
var hash = escapeCharacters(toggle.hash);
528+
var hash;
529+
try {
530+
hash = escapeCharacters(decodeURIComponent(toggle.hash));
531+
} catch(e) {
532+
hash = escapeCharacters(toggle.hash);
533+
}
534+
console.log(hash);
529535

530536
// Get the anchored element
531537
var anchor;

dist/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/smooth-scroll.polyfills.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v16.1.0
2+
* smooth-scroll v16.1.1
33
* Animate scrolling to anchor links
44
* (c) 2019 Chris Ferdinandi
55
* MIT License
@@ -595,7 +595,13 @@ if (window.Element && !Element.prototype.closest) {
595595
if (toggle.hostname !== window.location.hostname || toggle.pathname !== window.location.pathname || !/#/.test(toggle.href)) return;
596596

597597
// Get an escaped version of the hash
598-
var hash = escapeCharacters(toggle.hash);
598+
var hash;
599+
try {
600+
hash = escapeCharacters(decodeURIComponent(toggle.hash));
601+
} catch(e) {
602+
hash = escapeCharacters(toggle.hash);
603+
}
604+
console.log(hash);
599605

600606
// Get the anchored element
601607
var anchor;

0 commit comments

Comments
 (0)