Skip to content

Commit dacb30a

Browse files
committed
Fix path normalization of "/.."
Closes #2404.
1 parent 362df17 commit dacb30a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/elixir/lib/path.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@ defmodule Path do
548548

549549
defp normalize(path), do: normalize(split(path), [])
550550

551+
defp normalize([".."|t], ["/"|_] = acc) do
552+
normalize t, acc
553+
end
554+
551555
defp normalize([".."|t], [_|acc]) do
552556
normalize t, acc
553557
end

lib/elixir/test/elixir/path_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ defmodule PathTest do
111111
strip_drive_letter_if_windows) == "/bar"
112112

113113
assert Path.expand("bar/../bar", "foo") == Path.expand("foo/bar")
114+
115+
assert (Path.expand("/..") |> strip_drive_letter_if_windows) == "/"
114116
end
115117

116118
test :relative_to do

0 commit comments

Comments
 (0)