Sha256: 9277a63780528b565bd0280e02d82b100d56be75ca26e0591c31b5be3c4764dd

Contents?: true

Size: 735 Bytes

Versions: 4

Compression:

Stored size: 735 Bytes

Contents

module Conjur
  module Escape
    module ClassMethods
      def path_escape(str)
        path_or_query_escape str
      end

      def query_escape(str)
        path_or_query_escape str
      end
      
      def path_or_query_escape(str)
        return "false" unless str
        str = str.id if str.respond_to?(:id)
        # Leave colons and forward slashes alone
        require 'uri'
        pattern = URI::PATTERN::UNRESERVED + ":\\/@"
        URI.escape(str.to_s, Regexp.new("[^#{pattern}]"))
      end
    end
    
    def self.included(base)
      base.extend ClassMethods
    end

    def path_escape(str)
      self.class.path_escape str
    end

    def query_escape(str)
      self.class.query_escape str
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
conjur-api-2.1.3 lib/conjur/escape.rb
conjur-api-2.1.2 lib/conjur/escape.rb
conjur-api-2.1.1 lib/conjur/escape.rb
conjur-api-2.1.0 lib/conjur/escape.rb