on master help sign in
Merge pull request #287 from ckipp01/bugfix/space-in-hallway
68e83edЛu Лinveгa
scripts/hallway.js+7−2
@@ -11,7 +11,7 @@ function Hallway (sites) {
11 this._el = document.createElement('div')
11 this._el = document.createElement('div')
12 this._el.id = 'hallway'
12 this._el.id = 'hallway'
13 const filterAndPage = window.location.hash.split('^')
13 const filterAndPage = window.location.hash.split('^')
14− this.finder = { filter: filterAndPage[0].trim().replace('#', ''), page: filterAndPage[1] || 1 }
14+ this.finder = { filter: stripHash(filterAndPage[0]), page: filterAndPage[1] || 1 }
15 this.cache = null
15 this.cache = null
16
16
17 this._main = document.createElement('main')
17 this._main = document.createElement('main')
@@ -214,9 +214,14 @@ function escapeHtml (unsafe) {
214 return unsafe.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
214 return unsafe.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
215}
215}
216
216
217+function stripHash (hash) {
218+ const decoded = decodeURIComponent(hash)
219+ return decoded.charAt(0) === '#' ? decoded.substring(1) : decoded
220+}
221+
217function filter (name) {
222function filter (name) {
218 window.location.hash = name
223 window.location.hash = name
219 const filterAndPage = window.location.hash.split('^')
224 const filterAndPage = window.location.hash.split('^')
220− hallway.finder = { filter: filterAndPage[0].trim().replace('#', ''), page: filterAndPage[1] || 1 }
225+ hallway.finder = { filter: stripHash(filterAndPage[0]), page: filterAndPage[1] || 1 }
221 hallway.refresh()
226 hallway.refresh()
222}
227}