Sha256: 6dbb311ee202c020a64262da2cbe37fd25611dbcc6018bb35aa34267920fe1ac

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
require 'riak'

module Riak
  module Util
    # Methods for escaping URL segments.
    module Escape
      # CGI-escapes bucket or key names that may contain slashes for use in URLs.
      # @param [String] bucket_or_key the bucket or key name
      # @return [String] the escaped path segment
      def escape(bucket_or_key)
        CGI.escape(bucket_or_key.to_s).gsub("+", "%20")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
riak-client-0.8.3 lib/riak/util/escape.rb
riak-client-0.8.2 lib/riak/util/escape.rb
riak-client-0.8.1 lib/riak/util/escape.rb
riak-client-0.8.0 lib/riak/util/escape.rb