Skip to content

Commit

Permalink
Improve clarity of Path.safe_relative/2 argument names (#14167)
Browse files Browse the repository at this point in the history
Switches from `cwd` to `relative_to`, which is more generic and more consistent with possible use cases of the function.
  • Loading branch information
cloud8421 authored Jan 9, 2025
1 parent 56f745a commit 12b2004
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/elixir/lib/path.ex
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ defmodule Path do
* A `..` component would make it so that the path would traverse up above
the root of `relative_to`.
* A symbolic link in the path points to something above the root of `cwd`.
* A symbolic link in the path points to something above the root of `relative_to`.
## Examples
Expand All @@ -906,10 +906,10 @@ defmodule Path do
"""
@doc since: "1.14.0"
@spec safe_relative(t, t) :: {:ok, binary} | :error
def safe_relative(path, cwd \\ File.cwd!()) do
def safe_relative(path, relative_to \\ File.cwd!()) do
path = IO.chardata_to_string(path)

case :filelib.safe_relative_path(path, cwd) do
case :filelib.safe_relative_path(path, relative_to) do
:unsafe -> :error
relative_path -> {:ok, IO.chardata_to_string(relative_path)}
end
Expand Down

0 comments on commit 12b2004

Please sign in to comment.