mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Discard the port from the host before tokenizing it.
This commit is contained in:
parent
0fad6c6fde
commit
4cbba84a00
1 changed files with 6 additions and 1 deletions
|
@ -22,7 +22,11 @@
|
||||||
|
|
||||||
-spec split_host(Host::string()) -> Tokens::path_tokens().
|
-spec split_host(Host::string()) -> Tokens::path_tokens().
|
||||||
split_host(Host) ->
|
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())
|
-spec split_path(Path::string())
|
||||||
-> {Tokens::path_tokens(), Path::string(), Qs::string()}.
|
-> {Tokens::path_tokens(), Path::string(), Qs::string()}.
|
||||||
|
@ -112,6 +116,7 @@ split_host_test_() ->
|
||||||
{"cowboy.dev-extend.eu", ["cowboy", "dev-extend", "eu"]},
|
{"cowboy.dev-extend.eu", ["cowboy", "dev-extend", "eu"]},
|
||||||
{"dev-extend..eu", ["dev-extend", "eu"]},
|
{"dev-extend..eu", ["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",
|
||||||
["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
["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"]}
|
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue