Module: Hanami::CLI::URL Private

Defined in:
lib/hanami/cli/url.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Class Method Summary collapse

Class Method Details

.call(url) ⇒ Object Also known as: []

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hanami/cli/url.rb', line 17

def call(url)
  result = url
  result = URI.parse(result).path

  unless valid?(result)
    raise InvalidURLError.new(url)
  end

  result
rescue URI::InvalidURIError
  raise InvalidURLError.new(url)
end

.valid?(url) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 2.0.0



33
34
35
36
37
# File 'lib/hanami/cli/url.rb', line 33

def valid?(url)
  return false if url.nil?

  url.start_with?(DEFAULT_URL_PREFIX)
end