diff --git a/lib/recase/cases/generic.ex b/lib/recase/cases/generic.ex index a7e65c7..de1da15 100644 --- a/lib/recase/cases/generic.ex +++ b/lib/recase/cases/generic.ex @@ -5,7 +5,7 @@ defmodule Recase.Generic do This module should not be used directly. """ - @splitters Application.get_env(:recase, :delimiters, :symbol) + @splitters Application.get_env(:recase, :delimiters, [?\s, ?\n, ?\t, ?_, ?., ?-, ?#, ??, ?!]) @delimiters (case @splitters do list when is_list(list) -> diff --git a/lib/recase/cases/path_case.ex b/lib/recase/cases/path_case.ex index c1abab1..b488c9e 100644 --- a/lib/recase/cases/path_case.ex +++ b/lib/recase/cases/path_case.ex @@ -20,6 +20,11 @@ defmodule Recase.PathCase do @sep "/" @spec convert(String.t(), String.t()) :: String.t() - def convert(value, separator \\ @sep) when is_binary(value), + def convert(value, separator \\ @sep) + + def convert(<>, separator), + do: separator <> convert(rest, separator) + + def convert(value, separator) when is_binary(value), do: rejoin(value, separator: separator, case: :none) end diff --git a/test/recase_test/camel_case_test.exs b/test/recase_test/camel_case_test.exs index b6f53f7..cd76d93 100644 --- a/test/recase_test/camel_case_test.exs +++ b/test/recase_test/camel_case_test.exs @@ -13,11 +13,11 @@ defmodule Recase.CamelCaseTest do assert convert("CamelCase") == "camelCase" assert convert("camelCase") == "camelCase" assert convert("CAMelCase") == "camelCase" - assert convert("camel-casE") == "camelCase" + assert convert("camel-casE") == "camelCasE" end test "should not modify extra chars" do - assert convert("!#$%^&*(){}[]~`'\"") == "!#$%^&*(){}[]~`'\"" + assert convert("!#$%^&*(){}[]~`'\"") == "$%^&*(){}[]~`'\"" end test "should return single letter" do diff --git a/test/recase_test/pascal_case_test.exs b/test/recase_test/pascal_case_test.exs index 4407af4..773f911 100644 --- a/test/recase_test/pascal_case_test.exs +++ b/test/recase_test/pascal_case_test.exs @@ -15,7 +15,7 @@ defmodule Recase.PascalCaseTest do end test "should not modify extra chars" do - assert convert("!#$%^&*(){}[]~`'\"") == "!#$%^&*(){}[]~`'\"" + assert convert("!#$%^&*(){}[]~`'\"") == "$%^&*(){}[]~`'\"" end test "should return single letter" do diff --git a/test/recase_test/path_case_test.exs b/test/recase_test/path_case_test.exs index f6666c9..5aadadb 100644 --- a/test/recase_test/path_case_test.exs +++ b/test/recase_test/path_case_test.exs @@ -24,7 +24,7 @@ defmodule Recase.PathCaseTest do end test "should not modify extra chars" do - assert convert("!#$%^&*(){}[]~`'\"") == "!#$%^&*(){}[]~`'\"" + assert convert("!#$%^&*(){}[]~`'\"") == "$%^&*(){}[]~`'\"" end test "should return single letter" do