From 4cbba84a00e40d25211617194a643763963ee81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 8 Apr 2011 12:12:46 +0200 Subject: Discard the port from the host before tokenizing it. --- src/cowboy_dispatcher.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cowboy_dispatcher.erl b/src/cowboy_dispatcher.erl index 8370d31..47da5cb 100644 --- a/src/cowboy_dispatcher.erl +++ b/src/cowboy_dispatcher.erl @@ -22,7 +22,11 @@ -spec split_host(Host::string()) -> Tokens::path_tokens(). split_host(Host) -> - string:tokens(Host, "."). + Host2 = case string:chr(Host, $:) of + 0 -> Host; + N -> lists:sublist(Host, N - 1) + end, + string:tokens(Host2, "."). -spec split_path(Path::string()) -> {Tokens::path_tokens(), Path::string(), Qs::string()}. @@ -112,6 +116,7 @@ split_host_test_() -> {"cowboy.dev-extend.eu", ["cowboy", "dev-extend", "eu"]}, {"dev-extend..eu", ["dev-extend", "eu"]}, {"dev-extend.eu", ["dev-extend", "eu"]}, + {"dev-extend.eu:8080", ["dev-extend", "eu"]}, {"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z", ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]} -- cgit v1.2.3