Class: Calendav::ContextualURL

Inherits:
Object
  • Object
show all
Defined in:
lib/calendav/contextual_url.rb

Class Method Summary collapse

Class Method Details

.call(host, url_or_path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/calendav/contextual_url.rb', line 7

def self.call(host, url_or_path)
  host = URI(host)
  return host.to_s if url_or_path.nil? || url_or_path.empty?

  if url_or_path.start_with?("/")
    host.dup.tap { |new_url| new_url.path = url_or_path }.to_s
  else
    URI(url_or_path).to_s
  end
end