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
260$.escapeRegexp = (string) ->260$.escapeRegexp = (string) ->
261 string.replace ESCAPE_REGEXP, "\\$1"261 string.replace ESCAPE_REGEXP, "\\$1"
262 262
263$.urlDecode = (string) ->
264 decodeURIComponent string.replace(/\+/g, '%20')
265
263#266#
264# Miscellaneous267# Miscellaneous
265#268#
assets/javascripts/views/search/search.coffee+1−1
@@ -116,4 +116,4 @@ class app.views.Search extends app.View · 115 unmodified lines
116 value116 value
117 117
118 getHashValue: ->118 getHashValue: ->
119 try (new RegExp "##{SEARCH_PARAM}=(.*)").exec(decodeURIComponent location.hash)?[1] catch119 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
76 76
77 extractHashValue: ->77 extractHashValue: ->
78 if value = @getHashValue()78 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}="
80 app.router.replaceHash(newHash)80 app.router.replaceHash(newHash)
81 value81 value
82 82
83 getHashValue: ->83 getHashValue: ->
84 try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec(decodeURIComponent location.hash)?[1] catch84 try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec($.urlDecode location.hash)?[1] catch