Path.basename

You're seeing just the function basename, go back to Path module for more information.

Specs

basename(t()) :: binary()

Returns the last component of the path or the path itself if it does not contain any directory separators.

Examples

iex> Path.basename("foo")
"foo"

iex> Path.basename("foo/bar")
"bar"

iex> Path.basename("/")
""
Link to this function

basename(path, extension)

View Source

Specs

basename(t(), t()) :: binary()

Returns the last component of path with the extension stripped.

This function should be used to remove a specific extension which may or may not be there.

Examples

iex> Path.basename("~/foo/bar.ex", ".ex")
"bar"

iex> Path.basename("~/foo/bar.exs", ".ex")
"bar.exs"

iex> Path.basename("~/foo/bar.old.ex", ".ex")
"bar.old"