Module: URI

Defined in:
lib/puppet/parser/functions/validate_ldap_uri.rb,
lib/puppet/parser/functions/validate_ldap_uri.rb

Overview

:nocov:

Defined Under Namespace

Classes: LDAPI

Class Method Summary collapse

Class Method Details

.parse(uri) ⇒ Object

This is an almost-duplicate of the method as found in 1.8.7



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/puppet/parser/functions/validate_ldap_uri.rb', line 22

def parse(uri)
  scheme, userinfo, host, port,
    registry, path, opaque, query, fragment = self.split(uri)

  # Ruby 1.8.7 parses `ldapi://%2fsome%2fpath` such that `%2fsome%2fpath`
  # is the registry attribute whereas 1.9+ parses that correctly as the
  # host(name) attribute so swap them prior to creating the object
  if scheme == 'ldapi' and host.nil? and not registry.nil?
    host, registry = registry, host
  end

  if scheme && @@schemes.include?(scheme.upcase)
    @@schemes[scheme.upcase].new(scheme, userinfo, host, port,
                                 registry, path, opaque, query,
                                 fragment)
  else
    Generic.new(scheme, userinfo, host, port,
                registry, path, opaque, query,
                fragment)
  end
end