diff options
author | Loïc Hoguin <[email protected]> | 2011-04-08 12:12:46 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-04-08 12:12:46 +0200 |
commit | 4cbba84a00e40d25211617194a643763963ee81b (patch) | |
tree | f9034984ee413df92dfa1c06fdb438fbaf3d8d7d /src | |
parent | 0fad6c6fde3ec12ef6b3cf59a3acb42d1c4c7d6b (diff) | |
download | cowboy-4cbba84a00e40d25211617194a643763963ee81b.tar.gz cowboy-4cbba84a00e40d25211617194a643763963ee81b.tar.bz2 cowboy-4cbba84a00e40d25211617194a643763963ee81b.zip |
Discard the port from the host before tokenizing it.
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_dispatcher.erl | 7 |
1 files changed, 6 insertions, 1 deletions
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"]} |