File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,8 @@ defmodule Mix.Utils do
194
194
underscore ( rest )
195
195
end
196
196
197
+ def underscore ( "" ) , do: ""
198
+
197
199
def underscore ( << h , t :: binary >> ) do
198
200
<< to_lower_char ( h ) >> <> do_underscore ( t , h )
199
201
end
@@ -210,6 +212,12 @@ defmodule Mix.Utils do
210
212
<< ?_ >> <> do_underscore ( t , ?- )
211
213
end
212
214
215
+ defp do_underscore ( << ".." , t :: binary >> , _ ) do
216
+ << ".." >> <> underscore ( t )
217
+ end
218
+
219
+ defp do_underscore ( << ?. >> , _ ) , do: << ?. >>
220
+
213
221
defp do_underscore ( << ?. , t :: binary >> , _ ) do
214
222
<< ?/ >> <> underscore ( t )
215
223
end
@@ -230,6 +238,8 @@ defmodule Mix.Utils do
230
238
Mix.Utils.camelize "foo_bar" #=> "FooBar"
231
239
232
240
"""
241
+ def camelize ( "" ) , do: ""
242
+
233
243
def camelize ( << ?_ , t :: binary >> ) do
234
244
camelize ( t )
235
245
end
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ defmodule Mix.UtilsTest do
52
52
assert Mix.Utils . underscore ( "FoBaZa" ) == "fo_ba_za"
53
53
assert Mix.Utils . underscore ( "Foo.Bar" ) == "foo/bar"
54
54
assert Mix.Utils . underscore ( Foo.Bar ) == "foo/bar"
55
+ assert Mix.Utils . underscore ( "" ) == ""
56
+ assert Mix.Utils . underscore ( ".." ) == ".."
57
+ assert Mix.Utils . underscore ( "/.." ) == "/.."
58
+ assert Mix.Utils . underscore ( "foo/../bar" ) == "foo/../bar"
55
59
end
56
60
57
61
test :camelize do
@@ -63,6 +67,7 @@ defmodule Mix.UtilsTest do
63
67
assert Mix.Utils . camelize ( "_foo" ) == "Foo"
64
68
assert Mix.Utils . camelize ( "foo__bar" ) == "FooBar"
65
69
assert Mix.Utils . camelize ( "foo/bar" ) == "Foo.Bar"
70
+ assert Mix.Utils . camelize ( "" ) == ""
66
71
end
67
72
68
73
test :extract_files do
You can’t perform that action at this time.
0 commit comments