Skip to content

Commit

Permalink
Go 1.15: Drop tests cases depending on changing URL behavior
Browse files Browse the repository at this point in the history
Go 1.15's net/url package changes the handling of escaped URL fragments to preserve the original escaping when possible.

For example,

fmt.Println(url.Parse("https://example.com/amp.html#htmlURL=http%3A%2F%2Fbar.com%2Fbaz"))
// Go 1.14: https://example.com/amp.html#htmlURL=http://bar.com/baz <nil>
// Go 1.15: https://example.com/amp.html#htmlURL=http%3A%2F%2Fbar.com%2Fbaz <nil>

Upstream change: https://go.googlesource.com/go/+/8c00e07#

Drop two test cases that depend on the exact behavior of Go 1.14, which will break when run with Go 1.15. These tests have comments indicating that the preferred result would be that of Go 1.15.

Since these tests appear to exist specifically to exercise the undesired path (there are other test cases exercising escaping URL fragments), dropping the tests seems simplest.

PiperOrigin-RevId: 312422252
  • Loading branch information
Googler authored and banaag committed May 26, 2020
1 parent aeca3fe commit 25169c1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
7 changes: 0 additions & 7 deletions internal/url/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ func TestString(t *testing.T) {
"https://foo.com/i haz spaces?q=i haz spaces",
"https://foo.com/i%20haz%20spaces?q=i%20haz%20spaces",
},
{
// TODO(b/123017837): Go escapes only certain chars in fragments.
"fragment not entirely reescaped", // This is intrinsic Go URL behavior.
"https://example.com/amp.html#htmlURL=http%3A%2F%2Fbar.com%2Fbaz",
//does not produce: "https://example.com/amp.html#htmlURL=http%3A%2F%2Fbar.com%2Fbaz",
"https://example.com/amp.html#htmlURL=http://bar.com/baz",
},
{
"fragment with space and quote reescaped",
"https://example.com/amp.html#fragment-\" ",
Expand Down
9 changes: 0 additions & 9 deletions transformer/internal/amphtml/urls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ func TestToAbsoluteURL(t *testing.T) {
documentURL: otherURL,
expected: rootURL + "#dogs",
},
{
// TODO(b/123017837): Go escapes only certain chars in fragments.
desc: "fragment not entirely reescaped", // This is intrinsic Go URL behavior.
input: "https://example.com/amp.html#htmlURL=http%3A%2F%2Fbar.com%2Fbaz",
baseURL: rootURL,
documentURL: rootURL,
//expected: "https://example.com/amp.html#htmlURL=http%3A%2F%2Fbar.com%2Fbaz",
expected: "https://example.com/amp.html#htmlURL=http://bar.com/baz",
},
{
desc: "fragment with space and quote reescaped",
input: "https://example.com/amp.html#fragment-\" ",
Expand Down

0 comments on commit 25169c1

Please sign in to comment.