Method: Nmap::XML::CPE::URL.parse

Defined in:
lib/nmap/xml/cpe/url.rb

.parse(url) ⇒ URL

Parses a CPE URL.

Parameters:

  • url (String)

    The raw URL.

Returns:

  • (URL)

    The parsed URL.

Since:

  • 1.0.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nmap/xml/cpe/url.rb', line 32

def self.parse(url)
  scheme,
    part,
    vendor,
    product,
    version,
    update,
    edition,
    language = url.split(':',8)

  unless scheme == 'cpe'
    raise(ArgumentError,"CPE URLs must begin with 'cpe:'")
  end

  vendor   = vendor.to_sym
  product  = product.to_sym
  language = language.to_sym if language

  return new(
    PARTS[part],
    vendor,
    product,
    version,
    update,
    edition,
    language
  )
end