Skip to content

Commit 3ba5e44

Browse files
author
José Valim
committed
Ensure we properly underscore acronyms followed by paths
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
1 parent 1d74dda commit 3ba5e44

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/mix/lib/mix/utils.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ defmodule Mix.Utils do
171171
<<to_lower_char(h)>> <> do_underscore(t, h)
172172
end
173173

174-
defp do_underscore(<<h, t, rest :: binary>>, _) when h in ?A..?Z and not t in ?A..?Z do
174+
defp do_underscore(<<h, t, rest :: binary>>, _) when h in ?A..?Z and not (t in ?A..?Z or t == ?.) do
175175
<<?_, to_lower_char(h), t>> <> do_underscore(rest, t)
176176
end
177177

lib/mix/test/mix/utils_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ defmodule Mix.UtilsTest do
3737
assert Mix.Utils.underscore("FoBaZa") == "fo_ba_za"
3838
assert Mix.Utils.underscore("Foo.Bar") == "foo/bar"
3939
assert Mix.Utils.underscore(Foo.Bar) == "foo/bar"
40+
assert Mix.Utils.underscore("API.V1.User") == "api/v1/user"
4041
assert Mix.Utils.underscore("") == ""
4142
assert Mix.Utils.underscore("..") == ".."
4243
assert Mix.Utils.underscore("/..") == "/.."

0 commit comments

Comments
 (0)