Method: URI#basename

Defined in:
lib/grubby/core_ext/uri.rb

#basenameString

Returns the basename of the URI’s path, a la File.basename.

Examples:

URI("https://example.com/foo/bar").basename  # == "bar"
URI("https://example.com/foo").basename      # == "foo"
URI("https://example.com/").basename         # == ""

Returns:



11
12
13
# File 'lib/grubby/core_ext/uri.rb', line 11

def basename
  self.path == "/" ? "" : ::File.basename(self.path)
end