Class: Yast::URLRecodeClass

Inherits:
Module
  • Object
show all
Defined in:
library/types/src/modules/URLRecode.rb

Overview

A drop-in replacement of an earlier Perl implementation

Constant Summary

USERNAME_PASSWORD_FRAGMENT_SAFE_CHARS =

these will be substituted to a regex character class

"-A-Za-z0-9_.!~*'()".freeze
PATH_SAFE_CHARS =
"-A-Za-z0-9_.!~*'()/:".freeze
QUERY_SAFE_CHARS =
"-A-Za-z0-9_.!~*'()/:=&".freeze

Instance Method Summary collapse

Instance Method Details

#EscapePassword(input) ⇒ String

Escape password, user name and fragment part of URL string



18
19
20
# File 'library/types/src/modules/URLRecode.rb', line 18

def EscapePassword(input)
  escape(input, USERNAME_PASSWORD_FRAGMENT_SAFE_CHARS)
end

#EscapePath(input) ⇒ String

Escape path part of URL string



25
26
27
# File 'library/types/src/modules/URLRecode.rb', line 25

def EscapePath(input)
  escape(input, PATH_SAFE_CHARS)
end

#EscapeQuery(input) ⇒ String

Escape path part of URL string



32
33
34
# File 'library/types/src/modules/URLRecode.rb', line 32

def EscapeQuery(input)
  escape(input, QUERY_SAFE_CHARS)
end

#UnEscape(input) ⇒ String

UnEscape an URL string, replace %<Hexnum><HexNum> sequences by character



40
41
42
# File 'library/types/src/modules/URLRecode.rb', line 40

def UnEscape(input)
  input.gsub(/%([0-9A-Fa-f]{2})/) { Regexp.last_match[1].to_i(16).chr }.force_encoding(input.encoding)
end