summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2018-09-26 09:39:09 +0100
committerVincent Sanders <vince@kyllikki.org>2018-09-26 17:21:33 +0100
commit9100fcb4095cf8858d4cd2c613bff69ceb4f71ec (patch)
treeaad9e4c8246f10ba5d12d8175bcec5fdc3b3f0dc /test
parent83512a6ff529c7c5cb6315167cba1cf132e6a67a (diff)
downloadnetsurf-9100fcb4095cf8858d4cd2c613bff69ceb4f71ec.tar.gz
netsurf-9100fcb4095cf8858d4cd2c613bff69ceb4f71ec.tar.bz2
improve nsurl query handling.
Alter the handling of query values within nsurl to be like fragments. This ensures callers never have to care about the query punctuation, e.g. the question mark This also means the strings generated will no longer have trailing question marks which now conforms to behaviour in whatwg url spec on url serializing in section 4.5
Diffstat (limited to 'test')
-rw-r--r--test/nsurl.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/test/nsurl.c b/test/nsurl.c
index ba024291b..631e7ae2c 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -428,9 +428,9 @@ static const struct test_pairs join_tests[] = {
{ " ", "http://a/b/c/d;p?q" },
{ "/", "http://a/" },
{ " / ", "http://a/" },
- { " ? ", "http://a/b/c/d;p?" },
+ { " ? ", "http://a/b/c/d;p" },
{ " h ", "http://a/b/c/h" },
- { "//foo?", "http://foo/?" },
+ { "//foo?", "http://foo/" },
{ "//foo#bar", "http://foo/#bar" },
{ "//foo/", "http://foo/" },
{ "http://<!--#echo var=", "http://<!--/#echo%20var="},
@@ -531,21 +531,25 @@ END_TEST
*/
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
- "?magical=true&result=win",
+ "magical=true&result=win",
"http://netsurf-browser.org/?magical=true&result=win"},
{ "http://netsurf-browser.org/?magical=true#fragment",
- "?magical=true&result=win",
+ "magical=true&result=win",
"http://netsurf-browser.org/?magical=true&result=win#fragment"},
{ "http://netsurf-browser.org/#fragment",
- "?magical=true&result=win",
+ "magical=true&result=win",
"http://netsurf-browser.org/?magical=true&result=win#fragment"},
{ "http://netsurf-browser.org/path",
- "?magical=true",
+ "magical=true",
"http://netsurf-browser.org/path?magical=true"},
+ { "http://netsurf-browser.org/path?magical=true",
+ "",
+ "http://netsurf-browser.org/path"},
+
};
/**
@@ -655,7 +659,7 @@ static const struct test_compare component_tests[] = {
{ "http://u:p@a:66/b/c/d;p?q#f", "a", NSURL_HOST, true },
{ "http://u:p@a:66/b/c/d;p?q#f", "66", NSURL_PORT, true },
{ "http://u:p@a:66/b/c/d;p?q#f", "/b/c/d;p", NSURL_PATH, true },
- { "http://u:p@a:66/b/c/d;p?q#f", "?q", NSURL_QUERY, true },
+ { "http://u:p@a:66/b/c/d;p?q#f", "q", NSURL_QUERY, true },
{ "http://u:p@a:66/b/c/d;p?q#f", "f", NSURL_FRAGMENT, true },
{ "file:", "file", NSURL_SCHEME, true },
@@ -667,6 +671,11 @@ static const struct test_compare component_tests[] = {
{ "file:", NULL, NSURL_QUERY, false },
{ "file:", NULL, NSURL_FRAGMENT, false },
+ { "http://u:p@a:66/b/c/d;p?q=v#f", "q=v", NSURL_QUERY, true },
+ { "http://u:p@a:66/b/c/d;p?q=v", "q=v", NSURL_QUERY, true },
+ { "http://u:p@a:66/b/c/d;p?q=v&q1=v1#f", "q=v&q1=v1", NSURL_QUERY, true },
+ { "http://u:p@a:66/b/c/d;p?q=v&q1=v1", "q=v&q1=v1", NSURL_QUERY, true },
+
};
@@ -1167,12 +1176,11 @@ START_TEST(nsurl_api_assert_replace_query3_test)
nsurl *url;
nsurl *res;
nserror err;
- const char *rel = "moo";
err = nsurl_create(base_str, &url);
ck_assert(err == NSERROR_OK);
- err = nsurl_replace_query(url, rel, &res);
+ err = nsurl_replace_query(url, NULL, &res);
ck_assert(err != NSERROR_OK);
nsurl_unref(url);