From a20bc0b9250928465684c9efbe711d3737c4892e Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 8 Feb 2022 11:08:26 +0200 Subject: [PATCH 1/6] uri_test.go replace xxx.com with example.com --- client_test.go | 2 +- server_timing_test.go | 2 +- uri_test.go | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client_test.go b/client_test.go index 033284d197..2678d0db84 100644 --- a/client_test.go +++ b/client_test.go @@ -808,7 +808,7 @@ func TestClientDoWithCustomHeaders(t *testing.T) { uri := "/foo/bar/baz?a=b&cd=12" headers := map[string]string{ "Foo": "bar", - "Host": "xxx.com", + "Host": "example.com", "Content-Type": "asdfsdf", "a-b-c-d-f": "", } diff --git a/server_timing_test.go b/server_timing_test.go index 6ed1cae031..1e7f6f2112 100644 --- a/server_timing_test.go +++ b/server_timing_test.go @@ -317,7 +317,7 @@ func newFakeListener(requestsCount, clientsCount, requestsPerConn int, request s var ( fakeResponse = []byte("Hello, world!") getRequest = "GET /foobar?baz HTTP/1.1\r\nHost: google.com\r\nUser-Agent: aaa/bbb/ccc/ddd/eee Firefox Chrome MSIE Opera\r\n" + - "Referer: http://xxx.com/aaa?bbb=ccc\r\nCookie: foo=bar; baz=baraz; aa=aakslsdweriwereowriewroire\r\n\r\n" + "Referer: http://example.com/aaa?bbb=ccc\r\nCookie: foo=bar; baz=baraz; aa=aakslsdweriwereowriewroire\r\n\r\n" postRequest = fmt.Sprintf("POST /foobar?baz HTTP/1.1\r\nHost: google.com\r\nContent-Type: foo/bar\r\nContent-Length: %d\r\n"+ "User-Agent: Opera Chrome MSIE Firefox and other/1.2.34\r\nReferer: http://google.com/aaaa/bbb/ccc\r\n"+ "Cookie: foo=bar; baz=baraz; aa=aakslsdweriwereowriewroire\r\n\r\n%s", diff --git a/uri_test.go b/uri_test.go index a605b46219..572dfa8f8d 100644 --- a/uri_test.go +++ b/uri_test.go @@ -240,7 +240,7 @@ func TestURIFullURI(t *testing.T) { testURIFullURI(t, "", "aa.com", "/foo/bar", "", &args, "http://aa.com/foo/bar") // empty hash - testURIFullURI(t, "fTP", "XXx.com", "/foo", "", &args, "ftp://xxx.com/foo") + testURIFullURI(t, "fTP", "example.com", "/foo", "", &args, "ftp://example.com/foo") // empty args testURIFullURI(t, "https", "xx.com", "/", "aaa", &args, "https://xx.com/#aaa") @@ -248,7 +248,7 @@ func TestURIFullURI(t *testing.T) { // non-empty args and non-ASCII path args.Set("foo", "bar") args.Set("xxx", "йух") - testURIFullURI(t, "", "xxx.com", "/тест123", "2er", &args, "http://xxx.com/%D1%82%D0%B5%D1%81%D1%82123?foo=bar&xxx=%D0%B9%D1%83%D1%85#2er") + testURIFullURI(t, "", "example.com", "/тест123", "2er", &args, "http://example.com/%D1%82%D0%B5%D1%81%D1%82123?foo=bar&xxx=%D0%B9%D1%83%D1%85#2er") // test with empty args and non-empty query string var u URI @@ -363,9 +363,9 @@ func TestURIParse(t *testing.T) { "http://foobar.com/bC?De=F#Gh", "foobar.com", "/bC", "/bC", "De=F", "Gh") // uri with hostname - testURIParse(t, &u, "xxx.com", "http://aaa.com/foo/bar?baz=aaa#ddd", + testURIParse(t, &u, "example.com", "http://aaa.com/foo/bar?baz=aaa#ddd", "http://aaa.com/foo/bar?baz=aaa#ddd", "aaa.com", "/foo/bar", "/foo/bar", "baz=aaa", "ddd") - testURIParse(t, &u, "xxx.com", "https://ab.com/f/b%20r?baz=aaa#ddd", + testURIParse(t, &u, "example.com", "https://ab.com/f/b%20r?baz=aaa#ddd", "https://ab.com/f/b%20r?baz=aaa#ddd", "ab.com", "/f/b r", "/f/b%20r", "baz=aaa", "ddd") // no slash after hostname in uri From fd88166c566e59b638269e5774062cfd58cf88b9 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 8 Feb 2022 11:09:36 +0200 Subject: [PATCH 2/6] uri_test.go replace foobar.com with example.com --- uri_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/uri_test.go b/uri_test.go index 572dfa8f8d..1ad1c909c4 100644 --- a/uri_test.go +++ b/uri_test.go @@ -234,7 +234,7 @@ func TestURIFullURI(t *testing.T) { var args Args // empty scheme, path and hash - testURIFullURI(t, "", "foobar.com", "", "", &args, "http://foobar.com/") + testURIFullURI(t, "", "example.com", "", "", &args, "http://example.com/") // empty scheme and hash testURIFullURI(t, "", "aa.com", "/foo/bar", "", &args, "http://aa.com/foo/bar") @@ -286,11 +286,11 @@ func TestURIParseNilHost(t *testing.T) { testURIParseScheme(t, "httPS://aaa.com", "https", "aaa.com", "/", "") // missing slash after hostname - testURIParseScheme(t, "http://foobar.com?baz=111", "http", "foobar.com", "/?baz=111", "") + testURIParseScheme(t, "http://example.com?baz=111", "http", "example.com", "/?baz=111", "") // slash in args - testURIParseScheme(t, "http://foobar.com?baz=111/222/xyz", "http", "foobar.com", "/?baz=111/222/xyz", "") - testURIParseScheme(t, "http://foobar.com?111/222/xyz", "http", "foobar.com", "/?111/222/xyz", "") + testURIParseScheme(t, "http://example.com?baz=111/222/xyz", "http", "example.com", "/?baz=111/222/xyz", "") + testURIParseScheme(t, "http://example.com?111/222/xyz", "http", "example.com", "/?111/222/xyz", "") } func testURIParseScheme(t *testing.T, uri, expectedScheme, expectedHost, expectedRequestURI, expectedHash string) { @@ -347,8 +347,8 @@ func TestURIParse(t *testing.T) { "http://xx/aa?ss", "xx", "/aa", "/aa", "ss", "") // args and hash - testURIParse(t, &u, "foobar.com", "/a.b.c?def=gkl#mnop", - "http://foobar.com/a.b.c?def=gkl#mnop", "foobar.com", "/a.b.c", "/a.b.c", "def=gkl", "mnop") + testURIParse(t, &u, "example.com", "/a.b.c?def=gkl#mnop", + "http://example.com/a.b.c?def=gkl#mnop", "example.com", "/a.b.c", "/a.b.c", "def=gkl", "mnop") // '?' and '#' in hash testURIParse(t, &u, "aaa.com", "/foo#bar?baz=aaa#bbb", @@ -359,8 +359,8 @@ func TestURIParse(t *testing.T) { "http://aa.com/Test%20+%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf", "aa.com", "/Test + при", "/Test%20+%20%D0%BF%D1%80%D0%B8", "asdf=%20%20&s=12", "sdf") // host in uppercase - testURIParse(t, &u, "FOObar.COM", "/bC?De=F#Gh", - "http://foobar.com/bC?De=F#Gh", "foobar.com", "/bC", "/bC", "De=F", "Gh") + testURIParse(t, &u, "example.com", "/bC?De=F#Gh", + "http://example.com/bC?De=F#Gh", "example.com", "/bC", "/bC", "De=F", "Gh") // uri with hostname testURIParse(t, &u, "example.com", "http://aaa.com/foo/bar?baz=aaa#ddd", From 1613bff1bd69dfa6493174f308ef65cf9e8117db Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 8 Feb 2022 11:29:55 +0200 Subject: [PATCH 3/6] uri_test.go use example.com inside of testURIUpdate() --- uri_test.go | 63 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/uri_test.go b/uri_test.go index 1ad1c909c4..efabeba087 100644 --- a/uri_test.go +++ b/uri_test.go @@ -107,28 +107,31 @@ func TestURIUpdate(t *testing.T) { t.Parallel() // full uri - testURIUpdate(t, "http://foo.bar/baz?aaa=22#aaa", "https://aa.com/bb", "https://aa.com/bb") + testURIUpdate(t, "http://example.net/dir/path1.html?param1=val1#fragment1", "https://example.com/dir/path2.html", "https://example.com/dir/path2.html") // empty uri - testURIUpdate(t, "http://aaa.com/aaa.html?234=234#add", "", "http://aaa.com/aaa.html?234=234#add") + testURIUpdate(t, "http://example.com/dir/path1.html?param1=val1#fragment1", "", "http://example.com/dir/path1.html?param1=val1#fragment1") // request uri - testURIUpdate(t, "ftp://aaa/xxx/yyy?aaa=bb#aa", "/boo/bar?xx", "ftp://aaa/boo/bar?xx") + testURIUpdate(t, "http://example.com/dir/path1.html?param1=val1#fragment1", "/dir/path2.html?param2=val2#fragment2", "http://example.com/dir/path2.html?param2=val2#fragment2") + + // schema + testURIUpdate(t, "http://example.com/dir/path1.html?param1=val1#fragment1", "https://example.com/dir/path1.html?param1=val1#fragment1", "https://example.com/dir/path1.html?param1=val1#fragment1") // relative uri - testURIUpdate(t, "http://foo.bar/baz/xxx.html?aaa=22#aaa", "bb.html?xx=12#pp", "http://foo.bar/baz/bb.html?xx=12#pp") - testURIUpdate(t, "http://xx/a/b/c/d", "../qwe/p?zx=34", "http://xx/a/b/qwe/p?zx=34") - testURIUpdate(t, "https://qqq/aaa.html?foo=bar", "?baz=434&aaa#xcv", "https://qqq/aaa.html?baz=434&aaa#xcv") - testURIUpdate(t, "http://foo.bar/baz", "~a/%20b=c,тест?йцу=ке", "http://foo.bar/~a/%20b=c,%D1%82%D0%B5%D1%81%D1%82?йцу=ке") - testURIUpdate(t, "http://foo.bar/baz", "/qwe#fragment", "http://foo.bar/qwe#fragment") - testURIUpdate(t, "http://foobar/baz/xxx", "aaa.html#bb?cc=dd&ee=dfd", "http://foobar/baz/aaa.html#bb?cc=dd&ee=dfd") + testURIUpdate(t, "http://example.com/baz/xxx.html?aaa=22#aaa", "bb.html?xx=12#pp", "http://example.com/baz/bb.html?xx=12#pp") + testURIUpdate(t, "http://example.com/a/b/c/d", "../qwe/p?zx=34", "http://example.com/a/b/qwe/p?zx=34") + testURIUpdate(t, "http://example.com/aaa.html?foo=bar", "?baz=434&aaa#xcv", "http://example.com/aaa.html?baz=434&aaa#xcv") + testURIUpdate(t, "http://example.com/baz", "~a/%20b=c,тест?йцу=ке", "http://example.com/~a/%20b=c,%D1%82%D0%B5%D1%81%D1%82?йцу=ке") + testURIUpdate(t, "http://example.com/baz", "/qwe#fragment", "http://example.com/qwe#fragment") + testURIUpdate(t, "http://example.com/baz/xxx", "aaa.html#bb?cc=dd&ee=dfd", "http://example.com/baz/aaa.html#bb?cc=dd&ee=dfd") // hash - testURIUpdate(t, "http://foo.bar/baz#aaa", "#fragment", "http://foo.bar/baz#fragment") + testURIUpdate(t, "http://example.com/#fragment1", "#fragment2", "http://example.com/#fragment2") // uri without scheme - testURIUpdate(t, "https://foo.bar/baz", "//aaa.bbb/cc?dd", "https://aaa.bbb/cc?dd") - testURIUpdate(t, "http://foo.bar/baz", "//aaa.bbb/cc?dd", "http://aaa.bbb/cc?dd") + testURIUpdate(t, "https://example.net/dir/path1.html", "//example.com/dir/path2.html", "https://example.com/dir/path2.html") + testURIUpdate(t, "http://example.net/dir/path1.html", "//example.com/dir/path2.html", "http://example.com/dir/path2.html") } func testURIUpdate(t *testing.T, base, update, result string) { @@ -237,13 +240,13 @@ func TestURIFullURI(t *testing.T) { testURIFullURI(t, "", "example.com", "", "", &args, "http://example.com/") // empty scheme and hash - testURIFullURI(t, "", "aa.com", "/foo/bar", "", &args, "http://aa.com/foo/bar") + testURIFullURI(t, "", "example.com", "/foo/bar", "", &args, "http://example.com/foo/bar") // empty hash testURIFullURI(t, "fTP", "example.com", "/foo", "", &args, "ftp://example.com/foo") // empty args - testURIFullURI(t, "https", "xx.com", "/", "aaa", &args, "https://xx.com/#aaa") + testURIFullURI(t, "https", "example.com", "/", "aaa", &args, "https://example.com/#aaa") // non-empty args and non-ASCII path args.Set("foo", "bar") @@ -282,8 +285,8 @@ func TestURIParseNilHost(t *testing.T) { testURIParseScheme(t, "HTtP://google.com/", "http", "google.com", "/", "") testURIParseScheme(t, "://google.com/xyz", "http", "google.com", "/xyz", "") testURIParseScheme(t, "//google.com/foobar", "http", "google.com", "/foobar", "") - testURIParseScheme(t, "fTP://aaa.com", "ftp", "aaa.com", "/", "") - testURIParseScheme(t, "httPS://aaa.com", "https", "aaa.com", "/", "") + testURIParseScheme(t, "fTP://example.com", "ftp", "example.com", "/", "") + testURIParseScheme(t, "httPS://example.com", "https", "example.com", "/", "") // missing slash after hostname testURIParseScheme(t, "http://example.com?baz=111", "http", "example.com", "/?baz=111", "") @@ -351,25 +354,25 @@ func TestURIParse(t *testing.T) { "http://example.com/a.b.c?def=gkl#mnop", "example.com", "/a.b.c", "/a.b.c", "def=gkl", "mnop") // '?' and '#' in hash - testURIParse(t, &u, "aaa.com", "/foo#bar?baz=aaa#bbb", - "http://aaa.com/foo#bar?baz=aaa#bbb", "aaa.com", "/foo", "/foo", "", "bar?baz=aaa#bbb") + testURIParse(t, &u, "example.com", "/foo#bar?baz=aaa#bbb", + "http://example.com/foo#bar?baz=aaa#bbb", "example.com", "/foo", "/foo", "", "bar?baz=aaa#bbb") // encoded path - testURIParse(t, &u, "aa.com", "/Test%20+%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf", - "http://aa.com/Test%20+%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf", "aa.com", "/Test + при", "/Test%20+%20%D0%BF%D1%80%D0%B8", "asdf=%20%20&s=12", "sdf") + testURIParse(t, &u, "example.com", "/Test%20+%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf", + "http://example.com/Test%20+%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf", "example.com", "/Test + при", "/Test%20+%20%D0%BF%D1%80%D0%B8", "asdf=%20%20&s=12", "sdf") // host in uppercase testURIParse(t, &u, "example.com", "/bC?De=F#Gh", "http://example.com/bC?De=F#Gh", "example.com", "/bC", "/bC", "De=F", "Gh") // uri with hostname - testURIParse(t, &u, "example.com", "http://aaa.com/foo/bar?baz=aaa#ddd", - "http://aaa.com/foo/bar?baz=aaa#ddd", "aaa.com", "/foo/bar", "/foo/bar", "baz=aaa", "ddd") + testURIParse(t, &u, "example.com", "http://example.com/foo/bar?baz=aaa#ddd", + "http://example.com/foo/bar?baz=aaa#ddd", "example.com", "/foo/bar", "/foo/bar", "baz=aaa", "ddd") testURIParse(t, &u, "example.com", "https://ab.com/f/b%20r?baz=aaa#ddd", "https://ab.com/f/b%20r?baz=aaa#ddd", "ab.com", "/f/b r", "/f/b%20r", "baz=aaa", "ddd") // no slash after hostname in uri - testURIParse(t, &u, "aaa.com", "http://google.com", + testURIParse(t, &u, "example.com", "http://google.com", "http://google.com/", "google.com", "/", "/", "", "") // uppercase hostname in uri @@ -377,16 +380,16 @@ func TestURIParse(t *testing.T) { "http://gogle.com/aaa", "gogle.com", "/aaa", "/aaa", "", "") // http:// in query params - testURIParse(t, &u, "aaa.com", "/foo?bar=http://google.com", - "http://aaa.com/foo?bar=http://google.com", "aaa.com", "/foo", "/foo", "bar=http://google.com", "") + testURIParse(t, &u, "example.com", "/foo?bar=http://google.com", + "http://example.com/foo?bar=http://google.com", "example.com", "/foo", "/foo", "bar=http://google.com", "") - testURIParse(t, &u, "aaa.com", "//relative", - "http://aaa.com/relative", "aaa.com", "/relative", "//relative", "", "") + testURIParse(t, &u, "example.com", "//relative", + "http://example.com/relative", "example.com", "/relative", "//relative", "", "") - testURIParse(t, &u, "", "//aaa.com//absolute", - "http://aaa.com/absolute", "aaa.com", "/absolute", "//absolute", "", "") + testURIParse(t, &u, "", "//example.com//absolute", + "http://example.com/absolute", "example.com", "/absolute", "//absolute", "", "") - testURIParse(t, &u, "", "//aaa.com\r\n\r\nGET x", + testURIParse(t, &u, "", "//example.com\r\n\r\nGET x", "http:///", "", "/", "", "", "") testURIParse(t, &u, "", "http://[fe80::1%25en0]/", From 5d224f5fcd76d205e064ddffa4eda3f328ba0ed9 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 8 Feb 2022 11:37:15 +0200 Subject: [PATCH 4/6] uri_test.go use example.com instead of google.com --- uri_test.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/uri_test.go b/uri_test.go index efabeba087..c75094c9ab 100644 --- a/uri_test.go +++ b/uri_test.go @@ -223,7 +223,7 @@ func TestURICopyTo(t *testing.T) { t.Fatalf("URICopyTo fail, u: \n%+v\ncopyu: \n%+v\n", u, copyU) //nolint:govet } - u.UpdateBytes([]byte("https://google.com/foo?bar=baz&baraz#qqqq")) + u.UpdateBytes([]byte("https://example.com/foo?bar=baz&baraz#qqqq")) u.CopyTo(©U) if !reflect.DeepEqual(u, copyU) { //nolint:govet t.Fatalf("URICopyTo fail, u: \n%+v\ncopyu: \n%+v\n", u, copyU) //nolint:govet @@ -255,9 +255,9 @@ func TestURIFullURI(t *testing.T) { // test with empty args and non-empty query string var u URI - u.Parse([]byte("google.com"), []byte("/foo?bar=baz&baraz#qqqq")) //nolint:errcheck + u.Parse([]byte("example.com"), []byte("/foo?bar=baz&baraz#qqqq")) //nolint:errcheck uri := u.FullURI() - expectedURI := "http://google.com/foo?bar=baz&baraz#qqqq" + expectedURI := "http://example.com/foo?bar=baz&baraz#qqqq" if string(uri) != expectedURI { t.Fatalf("Unexpected URI: %q. Expected %q", uri, expectedURI) } @@ -281,10 +281,10 @@ func testURIFullURI(t *testing.T, scheme, host, path, hash string, args *Args, e func TestURIParseNilHost(t *testing.T) { t.Parallel() - testURIParseScheme(t, "http://google.com/foo?bar#baz", "http", "google.com", "/foo?bar", "baz") - testURIParseScheme(t, "HTtP://google.com/", "http", "google.com", "/", "") - testURIParseScheme(t, "://google.com/xyz", "http", "google.com", "/xyz", "") - testURIParseScheme(t, "//google.com/foobar", "http", "google.com", "/foobar", "") + testURIParseScheme(t, "http://example.com/foo?bar#baz", "http", "example.com", "/foo?bar", "baz") + testURIParseScheme(t, "HTtP://example.com/", "http", "example.com", "/", "") + testURIParseScheme(t, "://example.com/xyz", "http", "example.com", "/xyz", "") + testURIParseScheme(t, "//example.com/foobar", "http", "example.com", "/foobar", "") testURIParseScheme(t, "fTP://example.com", "ftp", "example.com", "/", "") testURIParseScheme(t, "httPS://example.com", "https", "example.com", "/", "") @@ -342,12 +342,12 @@ func TestURIParse(t *testing.T) { var u URI // no args - testURIParse(t, &u, "aaa", "sdfdsf", - "http://aaa/sdfdsf", "aaa", "/sdfdsf", "sdfdsf", "", "") + testURIParse(t, &u, "example.com", "sdfdsf", + "http://example.com/sdfdsf", "example.com", "/sdfdsf", "sdfdsf", "", "") // args - testURIParse(t, &u, "xx", "/aa?ss", - "http://xx/aa?ss", "xx", "/aa", "/aa", "ss", "") + testURIParse(t, &u, "example.com", "/aa?ss", + "http://example.com/aa?ss", "example.com", "/aa", "/aa", "ss", "") // args and hash testURIParse(t, &u, "example.com", "/a.b.c?def=gkl#mnop", @@ -372,16 +372,16 @@ func TestURIParse(t *testing.T) { "https://ab.com/f/b%20r?baz=aaa#ddd", "ab.com", "/f/b r", "/f/b%20r", "baz=aaa", "ddd") // no slash after hostname in uri - testURIParse(t, &u, "example.com", "http://google.com", - "http://google.com/", "google.com", "/", "/", "", "") + testURIParse(t, &u, "example.com", "http://example.com", + "http://example.com/", "example.com", "/", "/", "", "") // uppercase hostname in uri testURIParse(t, &u, "abc.com", "http://GoGLE.com/aaa", "http://gogle.com/aaa", "gogle.com", "/aaa", "/aaa", "", "") // http:// in query params - testURIParse(t, &u, "example.com", "/foo?bar=http://google.com", - "http://example.com/foo?bar=http://google.com", "example.com", "/foo", "/foo", "bar=http://google.com", "") + testURIParse(t, &u, "example.com", "/foo?bar=http://example.com", + "http://example.com/foo?bar=http://example.com", "example.com", "/foo", "/foo", "bar=http://example.com", "") testURIParse(t, &u, "example.com", "//relative", "http://example.com/relative", "example.com", "/relative", "//relative", "", "") From d6572bcc95d45ded84937ccbcdc6deaaf43a53d5 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 8 Feb 2022 11:39:05 +0200 Subject: [PATCH 5/6] uri_test.go use example.com instead of google.com --- uri_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uri_test.go b/uri_test.go index c75094c9ab..9db4e35702 100644 --- a/uri_test.go +++ b/uri_test.go @@ -368,16 +368,16 @@ func TestURIParse(t *testing.T) { // uri with hostname testURIParse(t, &u, "example.com", "http://example.com/foo/bar?baz=aaa#ddd", "http://example.com/foo/bar?baz=aaa#ddd", "example.com", "/foo/bar", "/foo/bar", "baz=aaa", "ddd") - testURIParse(t, &u, "example.com", "https://ab.com/f/b%20r?baz=aaa#ddd", - "https://ab.com/f/b%20r?baz=aaa#ddd", "ab.com", "/f/b r", "/f/b%20r", "baz=aaa", "ddd") + testURIParse(t, &u, "example.net", "https://example.com/f/b%20r?baz=aaa#ddd", + "https://example.com/f/b%20r?baz=aaa#ddd", "example.com", "/f/b r", "/f/b%20r", "baz=aaa", "ddd") // no slash after hostname in uri testURIParse(t, &u, "example.com", "http://example.com", "http://example.com/", "example.com", "/", "/", "", "") // uppercase hostname in uri - testURIParse(t, &u, "abc.com", "http://GoGLE.com/aaa", - "http://gogle.com/aaa", "gogle.com", "/aaa", "/aaa", "", "") + testURIParse(t, &u, "example.net", "http://EXAMPLE.COM/aaa", + "http://example.com/aaa", "example.com", "/aaa", "/aaa", "", "") // http:// in query params testURIParse(t, &u, "example.com", "/foo?bar=http://example.com", From 665d143a8922a5c337b63e3c2458834989d76f13 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 8 Feb 2022 12:18:07 +0200 Subject: [PATCH 6/6] uri_test.go testURIUpdate() host with port --- uri_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/uri_test.go b/uri_test.go index 9db4e35702..c7f02817d7 100644 --- a/uri_test.go +++ b/uri_test.go @@ -132,6 +132,8 @@ func TestURIUpdate(t *testing.T) { // uri without scheme testURIUpdate(t, "https://example.net/dir/path1.html", "//example.com/dir/path2.html", "https://example.com/dir/path2.html") testURIUpdate(t, "http://example.net/dir/path1.html", "//example.com/dir/path2.html", "http://example.com/dir/path2.html") + // host with port + testURIUpdate(t, "http://example.net/", "//example.com:8080/", "http://example.com:8080/") } func testURIUpdate(t *testing.T, base, update, result string) { @@ -380,8 +382,8 @@ func TestURIParse(t *testing.T) { "http://example.com/aaa", "example.com", "/aaa", "/aaa", "", "") // http:// in query params - testURIParse(t, &u, "example.com", "/foo?bar=http://example.com", - "http://example.com/foo?bar=http://example.com", "example.com", "/foo", "/foo", "bar=http://example.com", "") + testURIParse(t, &u, "example.com", "/foo?bar=http://example.org", + "http://example.com/foo?bar=http://example.org", "example.com", "/foo", "/foo", "bar=http://example.org", "") testURIParse(t, &u, "example.com", "//relative", "http://example.com/relative", "example.com", "/relative", "//relative", "", "")