diff options
author | Loïc Hoguin <[email protected]> | 2013-02-06 18:38:13 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-02-06 18:38:13 +0100 |
commit | 8e1bbc2cbc83eef8d01fe39a082a7c0318380326 (patch) | |
tree | d421d9ba9395bc50bfafb2003f430e97d75d05bb /src | |
parent | 4e71cd0f14f6f4c617079aa614e65b88f6308727 (diff) | |
parent | 05a7fe0e2b937cd8c8f2b916770177a6ab4a67e7 (diff) | |
download | cowboy-8e1bbc2cbc83eef8d01fe39a082a7c0318380326.tar.gz cowboy-8e1bbc2cbc83eef8d01fe39a082a7c0318380326.tar.bz2 cowboy-8e1bbc2cbc83eef8d01fe39a082a7c0318380326.zip |
Merge branch 'no-unicode-uri' of git://github.com/dvv/cowboy
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_router.erl | 15 |
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) |