Created
March 10, 2010 16:44
-
-
Save johnthethird/328053 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This patch to the Ripple gem will properly escape key names with slashes and + signs | |
# in them. Nice for trying to store a file directory structure in Riak. | |
module Riak | |
class Client | |
class HTTPBackend | |
def path(*segments) | |
query = segments.extract_options!.to_param | |
uri = root_uri.merge(URI.escape(segments.join("/").gsub(/\/+/, "/").sub(/^\//, ''))).tap do |u| | |
u.query = query if query.present? | |
end | |
# This line is the patch... | |
uri.path = "#{$1}#{$2.gsub(%r{/},'%2F').gsub(%r{\+},'%2B')}" if uri.path =~ %r{(/[^/]+/[^/]+/)(.*)} | |
uri | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment