mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-27 20:59:00 +08:00
test and fix
This commit is contained in:
parent
3a46055e52
commit
e52a6184c4
@ -4049,7 +4049,7 @@ static struct url urlparse(const char *url) {
|
||||
u.port = 0;
|
||||
} else if (url[i] == ']') {
|
||||
u.port = 0; // IPv6 URLs, like http://[::1]/bar
|
||||
} else if (url[i] == ':' && u.port == 0) {
|
||||
} else if (url[i] == ':' && u.port == 0 && u.uri == 0) {
|
||||
u.port = i + 1;
|
||||
} else if (url[i] == '@' && u.user == 0 && u.pass == 0) {
|
||||
u.user = u.host;
|
||||
|
@ -21,7 +21,7 @@ static struct url urlparse(const char *url) {
|
||||
u.port = 0;
|
||||
} else if (url[i] == ']') {
|
||||
u.port = 0; // IPv6 URLs, like http://[::1]/bar
|
||||
} else if (url[i] == ':' && u.port == 0) {
|
||||
} else if (url[i] == ':' && u.port == 0 && u.uri == 0) {
|
||||
u.port = i + 1;
|
||||
} else if (url[i] == '@' && u.user == 0 && u.pass == 0) {
|
||||
u.user = u.host;
|
||||
|
@ -125,6 +125,7 @@ static void test_url(void) {
|
||||
ASSERT(vcmp(mg_url_host("p://u:p@bar:1234/a"), "bar"));
|
||||
ASSERT(vcmp(mg_url_host("p://u:p@[::1]:1234/a"), "::1"));
|
||||
ASSERT(vcmp(mg_url_host("p://u:p@[1:2::3]:1234/a"), "1:2::3"));
|
||||
ASSERT(vcmp(mg_url_host("p://foo/x:y/z"), "foo"));
|
||||
|
||||
// Port
|
||||
ASSERT(mg_url_port("foo:1234") == 1234);
|
||||
|
Loading…
Reference in New Issue
Block a user