Sha256: 6827ac98ceb826dc946ea74899ae0cfd4f552c3935a4f994d43325817f4fd432
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
module Hawkular module ClientUtils # Escapes the passed url part. This is necessary, # as many ids inside Hawkular can contain characters # that are invalid for an url/uri. # The passed value is duplicated # Does not escape the = character # @param [String] url_part Part of an url to be escaped # @return [String] escaped url_part as new string def hawk_escape(url_part) return url_part.to_s if url_part.is_a?(Numeric) url_part .to_s .dup .gsub('%', '%25') .gsub(' ', '%20') .gsub('[', '%5b') .gsub(']', '%5d') .gsub('|', '%7c') .gsub('(', '%28') .gsub(')', '%29') .gsub('/', '%2f') end # Escapes the passed url part. This is necessary, # as many ids inside Hawkular can contain characters # that are invalid for an url/uri. # The passed value is duplicated # Does escape the = character # @param [String] url_part Part of an url to be escaped # @return [String] escaped url_part as new string def hawk_escape_id(url_part) hawk_escape(url_part) .gsub('=', '%3d') .gsub(';', '%3b') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hawkular-client-3.0.2 | lib/hawkular/client_utils.rb |
hawkular-client-3.0.1 | lib/hawkular/client_utils.rb |
hawkular-client-3.0.0 | lib/hawkular/client_utils.rb |