Module: Promproto

Defined in:
lib/promproto.rb,
lib/promproto/cli.rb,
lib/promproto/version.rb

Defined Under Namespace

Classes: CLI

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.normalize_url(input) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/promproto.rb', line 8

def self.normalize_url(input)
  url = input.dup

  # Add http:// if no scheme
  unless url.match?(%r{^https?://})
    url = "http://#{url}"
  end

  # Parse to check/add path
  uri = URI.parse(url)

  # Add /metrics if path is empty or just /
  if uri.path.nil? || uri.path.empty? || uri.path == "/"
    uri.path = "/metrics"
  end

  uri.to_s
end