module Fog::Google

Constants

VERSION

Public Class Methods

escape(str,extra_exclude_chars = '') click to toggle source

CGI.escape, but without special treatment on spaces

# File lib/fog/google.rb, line 32
def self.escape(str,extra_exclude_chars = '')
  # '-' is a special character inside a regex class so it must be first or last.
  # Add extra excludes before the final '-' so it always remains trailing, otherwise
  # an unwanted range is created by mistake.
  str.gsub(/([^a-zA-Z0-9_.#{extra_exclude_chars}-]+)/) do
    '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  end
end