Last active
September 13, 2015 22:00
-
-
Save JordanMilne/a68bc9739a3c15969c7b to your computer and use it in GitHub Desktop.
URL parsing changes from Go 1.3.3 to 1.5.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original: http://example.com/foo/%2F/bar | |
Scheme: http | |
Hostname: example.com | |
Path: /foo///bar | |
Unparsed: http://example.com/foo///bar | |
Original: http%3A/%2Fexample.com/baz | |
Scheme: | |
Hostname: | |
Path: http://example.com/baz | |
Unparsed: http://example.com/baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original: http://example.com/foo/%2F/bar | |
Scheme: http | |
Hostname: example.com | |
Path: /foo///bar | |
Unparsed: http://example.com/foo/%2F/bar | |
Original: http%3A/%2Fexample.com/baz | |
Scheme: | |
Hostname: | |
Path: http://example.com/baz | |
Unparsed: http%3A/%2Fexample.com/baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "net/url" | |
func testUrlParser(toParse string) { | |
parsed, err := url.Parse(toParse) | |
if(err != nil) { | |
panic(err) | |
} | |
fmt.Printf("Original: %s\n", toParse) | |
fmt.Printf("Scheme: %s\n", parsed.Scheme) | |
fmt.Printf("Hostname: %s\n", parsed.Host) | |
fmt.Printf("Path: %s\n", parsed.Path) | |
fmt.Printf("Unparsed: %s\n\n", parsed) | |
} | |
func main() { | |
testUrlParser("http://example.com/foo/%2F/bar") | |
testUrlParser("http%3A/%2Fexample.com/baz") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment