History

Fix URL search fragment decoding

Fixes #45

Thibaut committed 12 years ago

Commit ce31de51 parent 994f8203 files · +6 −3Browse files

Unified · Split

3 files
  1. assets/javascripts/lib/util.coffee +3 −0
  2. assets/javascripts/views/search/search.coffee +1 −1
  3. assets/javascripts/views/search/search_scope.coffee +2 −2
assets/javascripts/lib/util.coffee+3−0
@@ -260,6 +260,9 @@ ESCAPE_REGEXP = /([.*+?^=!:${}()|\[\]\/\\])/g · 259 unmodified lines
260260 $.escapeRegexp = (string) ->
261261 string.replace ESCAPE_REGEXP, "\\$1"
262262
263+$.urlDecode = (string) ->
264+ decodeURIComponent string.replace(/\+/g, '%20')
265+
263266 #
264267 # Miscellaneous
265268 #
assets/javascripts/views/search/search.coffee+1−1
@@ -116,4 +116,4 @@ class app.views.Search extends app.View · 115 unmodified lines
116116 value
117117
118118 getHashValue: ->
119− try (new RegExp "##{SEARCH_PARAM}=(.*)").exec(decodeURIComponent location.hash)?[1] catch
119+ try (new RegExp "##{SEARCH_PARAM}=(.*)").exec($.urlDecode location.hash)?[1] catch
assets/javascripts/views/search/search_scope.coffee+2−2
@@ -76,9 +76,9 @@ class app.views.SearchScope extends app.View · 75 unmodified lines
7676
7777 extractHashValue: ->
7878 if value = @getHashValue()
79− newHash = decodeURIComponent(location.hash).replace "##{SEARCH_PARAM}=#{value} ", "##{SEARCH_PARAM}="
79+ newHash = $.urlDecode(location.hash).replace "##{SEARCH_PARAM}=#{value} ", "##{SEARCH_PARAM}="
8080 app.router.replaceHash(newHash)
8181 value
8282
8383 getHashValue: ->
84− try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec(decodeURIComponent location.hash)?[1] catch
84+ try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec($.urlDecode location.hash)?[1] catch