From 4bceee7fd28ea71dfda8c35d7d4e9a9e7e4e059d Mon Sep 17 00:00:00 2001 From: thawk Date: Fri, 30 Jul 2021 22:36:37 +0800 Subject: [PATCH] use decodeURIComponent() to get ID from URL hash --- js/impress.js | 3 ++- src/lib/util.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/impress.js b/js/impress.js index 44679c4..dce97a2 100644 --- a/js/impress.js +++ b/js/impress.js @@ -1204,7 +1204,8 @@ // Get id from url # by removing `#` or `#/` from the beginning, // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work - return byId( window.location.hash.replace( /^#\/?/, "" ) ); + var encoded = window.location.hash.replace( /^#\/?/, "" ); + return byId( decodeURIComponent( encoded ) ); }; // `getUrlParamValue` return a given URL parameter value if it exists diff --git a/src/lib/util.js b/src/lib/util.js index b0d3a93..d9aa38e 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -46,7 +46,8 @@ // Get id from url # by removing `#` or `#/` from the beginning, // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work - return byId( window.location.hash.replace( /^#\/?/, "" ) ); + var encoded = window.location.hash.replace( /^#\/?/, "" ); + return byId( decodeURIComponent( encoded ) ); }; // `getUrlParamValue` return a given URL parameter value if it exists