mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
improve url parser
This commit is contained in:
parent
d02297160c
commit
e2567a79e5
@ -1,6 +1,7 @@
|
||||
# 最新动态
|
||||
2022/04/01
|
||||
* 完善给edit、mledit和combo\_box增加了empty\_over状态(感谢雨欣提供补丁)
|
||||
* 完善URL解析并增加一些新的schema。
|
||||
|
||||
2022/03/31
|
||||
* 增加带统计功能的stream (感谢林福提供)
|
||||
|
@ -337,10 +337,6 @@ typedef struct _image_manager_t image_manager_t;
|
||||
struct _system_info_t;
|
||||
typedef struct _system_info_t system_info_t;
|
||||
|
||||
#define STR_SCHEMA_FILE "file://"
|
||||
#define STR_SCHEMA_HTTP "http://"
|
||||
#define STR_SCHEMA_HTTPS "https://"
|
||||
|
||||
#if defined(WITH_NANOVG_GL3) || defined(WITH_NANOVG_GL2) || defined(WITH_NANOVG_GLES3) || \
|
||||
defined(WITH_NANOVG_GLES2)
|
||||
#define WITH_GPU_GL 1
|
||||
|
@ -442,4 +442,11 @@ typedef struct _event_source_manager_t event_source_manager_t;
|
||||
#define tk_isprint(c) (((int)(c) < 128) && isprint(c))
|
||||
#define tk_isalpha(c) (((int)(c) < 128) && isalpha(c))
|
||||
|
||||
#define STR_SCHEMA_TCP "tcp://"
|
||||
#define STR_SCHEMA_UDP "udp://"
|
||||
#define STR_SCHEMA_SERIAL "serial://"
|
||||
#define STR_SCHEMA_FILE "file://"
|
||||
#define STR_SCHEMA_HTTP "http://"
|
||||
#define STR_SCHEMA_HTTPS "https://"
|
||||
|
||||
#endif /*TYPES_DEF_H*/
|
||||
|
@ -142,6 +142,7 @@ static url_t* url_parse(url_t* url, const char* surl) {
|
||||
break;
|
||||
}
|
||||
case '/': {
|
||||
p--;
|
||||
state = STATE_PATH;
|
||||
break;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ TEST(URL, http2) {
|
||||
url_t* url = url_create("http://www.zlg.cn/abc");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params == NULL, true);
|
||||
ASSERT_EQ(url->user_name == NULL, true);
|
||||
ASSERT_EQ(url->password == NULL, true);
|
||||
@ -113,7 +113,7 @@ TEST(URL, http4) {
|
||||
url_t* url = url_create("http://www.zlg.cn/abc?name=jim");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params != NULL, true);
|
||||
ASSERT_EQ(url->user_name == NULL, true);
|
||||
ASSERT_EQ(url->password == NULL, true);
|
||||
@ -126,7 +126,7 @@ TEST(URL, http5) {
|
||||
url_t* url = url_create("http://www.zlg.cn/abc?name=jim&");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params != NULL, true);
|
||||
ASSERT_EQ(url->user_name == NULL, true);
|
||||
ASSERT_EQ(url->password == NULL, true);
|
||||
@ -139,7 +139,7 @@ TEST(URL, http6) {
|
||||
url_t* url = url_create("http://www.zlg.cn/abc?name=jim&age=100");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params != NULL, true);
|
||||
ASSERT_EQ(url->user_name == NULL, true);
|
||||
ASSERT_EQ(url->password == NULL, true);
|
||||
@ -153,7 +153,7 @@ TEST(URL, http7) {
|
||||
url_t* url = url_create("http://www.zlg.cn/abc?name=jim&age=100&");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params != NULL, true);
|
||||
ASSERT_EQ(url->user_name == NULL, true);
|
||||
ASSERT_EQ(url->password == NULL, true);
|
||||
@ -167,7 +167,7 @@ TEST(URL, http8) {
|
||||
url_t* url = url_create("http://jim:1234@www.zlg.cn/abc?name=jim&age=100&");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params != NULL, true);
|
||||
ASSERT_STREQ(url->user_name, "jim");
|
||||
ASSERT_STREQ(url->password, "1234");
|
||||
@ -181,7 +181,7 @@ TEST(URL, http9) {
|
||||
url_t* url = url_create("jim:1234@www.zlg.cn/abc?name=jim&age=100&");
|
||||
ASSERT_STREQ(url->schema, "http");
|
||||
ASSERT_STREQ(url->host, "www.zlg.cn");
|
||||
ASSERT_STREQ(url->path, "abc");
|
||||
ASSERT_STREQ(url->path, "/abc");
|
||||
ASSERT_EQ(url->params != NULL, true);
|
||||
ASSERT_STREQ(url->user_name, "jim");
|
||||
ASSERT_STREQ(url->password, "1234");
|
||||
@ -286,7 +286,17 @@ TEST(URL, asset) {
|
||||
ASSERT_STREQ(url->schema, "asset");
|
||||
ASSERT_STREQ(url->host, "ui");
|
||||
ASSERT_EQ(url->params == NULL, true);
|
||||
ASSERT_STREQ(url->path, "main");
|
||||
ASSERT_STREQ(url->path, "/main");
|
||||
|
||||
url_destroy(url);
|
||||
}
|
||||
|
||||
TEST(URL, serial) {
|
||||
url_t* url = url_create("serial:///dev/cu.usbserial-1410");
|
||||
ASSERT_STREQ(url->schema, "serial");
|
||||
ASSERT_STREQ(url->host, "");
|
||||
ASSERT_EQ(url->params == NULL, true);
|
||||
ASSERT_STREQ(url->path, "/dev/cu.usbserial-1410");
|
||||
|
||||
url_destroy(url);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user