Fix URL search fragment decoding

Fixes #45
This commit is contained in:
Thibaut 2014-01-25 10:06:48 -05:00
parent 994f8207cd
commit ce31de5c3f
3 changed files with 6 additions and 3 deletions

View file

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

View file

@ -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

View file

@ -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