aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVladimir Dronnikov <[email protected]>2013-01-25 02:36:05 +0000
committerVladimir Dronnikov <[email protected]>2013-01-25 02:36:05 +0000
commit05a7fe0e2b937cd8c8f2b916770177a6ab4a67e7 (patch)
tree742d29f88f6357029a59dc825eef72bfe834fca5 /src
parent855e9652fa40673d8f1ff40fd262963941e28fef (diff)
downloadcowboy-05a7fe0e2b937cd8c8f2b916770177a6ab4a67e7.tar.gz
cowboy-05a7fe0e2b937cd8c8f2b916770177a6ab4a67e7.tar.bz2
cowboy-05a7fe0e2b937cd8c8f2b916770177a6ab4a67e7.zip
Do not transform URIs to Unicode
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_router.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cowboy_router.erl b/src/cowboy_router.erl
index a4597ed..10db3f7 100644
--- a/src/cowboy_router.erl
+++ b/src/cowboy_router.erl
@@ -78,7 +78,7 @@ compile([{HostMatch, Constraints, Paths}|Tail], Acc) ->
compile(Tail, Hosts ++ Acc).
compile_host(HostMatch) when is_list(HostMatch) ->
- compile_host(unicode:characters_to_binary(HostMatch));
+ compile_host(list_to_binary(HostMatch));
compile_host(HostMatch) when is_binary(HostMatch) ->
compile_rules(HostMatch, $., [], [], <<>>).
@@ -88,7 +88,7 @@ compile_paths([{PathMatch, Handler, Opts}|Tail], Acc) ->
compile_paths([{PathMatch, [], Handler, Opts}|Tail], Acc);
compile_paths([{PathMatch, Constraints, Handler, Opts}|Tail], Acc)
when is_list(PathMatch) ->
- compile_paths([{unicode:characters_to_binary(PathMatch),
+ compile_paths([{list_to_binary(PathMatch),
Constraints, Handler, Opts}|Tail], Acc);
compile_paths([{'_', Constraints, Handler, Opts}|Tail], Acc) ->
compile_paths(Tail, [{'_', Constraints, Handler, Opts}] ++ Acc);
@@ -391,10 +391,14 @@ compile_test_() ->
{[<<"path">>, <<"to">>, <<"resource">>], [], hb, ob}]}]},
{[{'_', [{"/path/to/resource/", h, o}]}],
[{'_', [], [{[<<"path">>, <<"to">>, <<"resource">>], [], h, o}]}]},
+ {[{'_', [{"/путь/к/ресурсу/", h, o}]}],
+ [{'_', [], [{[<<"путь">>, <<"к">>, <<"ресурсу">>], [], h, o}]}]},
{[{"cowboy.example.org.", [{'_', h, o}]}],
[{[<<"org">>, <<"example">>, <<"cowboy">>], [], [{'_', [], h, o}]}]},
{[{".cowboy.example.org", [{'_', h, o}]}],
[{[<<"org">>, <<"example">>, <<"cowboy">>], [], [{'_', [], h, o}]}]},
+ {[{"некий.сайт.рф.", [{'_', h, o}]}],
+ [{[<<"рф">>, <<"сайт">>, <<"некий">>], [], [{'_', [], h, o}]}]},
{[{":subdomain.example.org", [{"/hats/:name/prices", h, o}]}],
[{[<<"org">>, <<"example">>, subdomain], [], [
{[<<"hats">>, name, <<"prices">>], [], h, o}]}]},
@@ -502,6 +506,9 @@ match_info_test_() ->
]},
{[<<"eu">>, <<"ninenines">>, '...'], [], [
{'_', [], match_any, []}
+ ]},
+ {[<<"рф">>, <<"сайт">>], [], [
+ {[<<"путь">>, '...'], [], match_path, []}
]}
],
Tests = [
@@ -516,7 +523,9 @@ match_info_test_() ->
{<<"www.ninenines.eu">>, <<"/pathinfo/is/next/path_info">>,
{ok, match_path, [], [], undefined, [<<"path_info">>]}},
{<<"www.ninenines.eu">>, <<"/pathinfo/is/next/foo/bar">>,
- {ok, match_path, [], [], undefined, [<<"foo">>, <<"bar">>]}}
+ {ok, match_path, [], [], undefined, [<<"foo">>, <<"bar">>]}},
+ {<<"сайт.рф">>, <<"/путь/домой">>,
+ {ok, match_path, [], [], undefined, [<<"домой">>]}}
],
[{lists:flatten(io_lib:format("~p, ~p", [H, P])), fun() ->
R = match(Dispatch, H, P)