Fix URL search fragment decoding

Fixes #45
pull/50/merge
Thibaut 11 years ago
parent 994f8207cd
commit ce31de5c3f

@ -260,6 +260,9 @@ ESCAPE_REGEXP = /([.*+?^=!:${}()|\[\]\/\\])/g
$.escapeRegexp = (string) ->
string.replace ESCAPE_REGEXP, "\\$1"
$.urlDecode = (string) ->
decodeURIComponent string.replace(/\+/g, '%20')
#
# Miscellaneous
#

@ -116,4 +116,4 @@ class app.views.Search extends app.View
value
getHashValue: ->
try (new RegExp "##{SEARCH_PARAM}=(.*)").exec(decodeURIComponent location.hash)?[1] catch
try (new RegExp "##{SEARCH_PARAM}=(.*)").exec($.urlDecode location.hash)?[1] catch

@ -76,9 +76,9 @@ class app.views.SearchScope extends app.View
extractHashValue: ->
if value = @getHashValue()
newHash = decodeURIComponent(location.hash).replace "##{SEARCH_PARAM}=#{value} ", "##{SEARCH_PARAM}="
newHash = $.urlDecode(location.hash).replace "##{SEARCH_PARAM}=#{value} ", "##{SEARCH_PARAM}="
app.router.replaceHash(newHash)
value
getHashValue: ->
try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec(decodeURIComponent location.hash)?[1] catch
try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec($.urlDecode location.hash)?[1] catch

Loading…
Cancel
Save