Method: Wgit::Url#to_path

Defined in:
lib/wgit/url.rb

#to_pathWgit::Url? Also known as: path

Returns the path of this URL e.g. the bit after the host without slashes. For example: Wgit::Url.new("http://www.google.co.uk/about.html/").to_path returns "about.html". See Wgit::Url#to_endpoint if you want the slashes.

Returns:

  • (Wgit::Url, nil)

    Path of self e.g. about.html or nil.



360
361
362
363
364
365
366
# File 'lib/wgit/url.rb', line 360

def to_path
  path = @uri.path
  return nil if path.nil? || path.empty?
  return Wgit::Url.new('/') if path == '/'

  Wgit::Url.new(path).omit_slashes
end