Skip to content

Instantly share code, notes, and snippets.

@JordanMilne

JordanMilne/go-1.3.3.txt

Last active Sep 13, 2015
Embed
What would you like to do?
URL parsing changes from Go 1.3.3 to 1.5.1
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
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
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
You can’t perform that action at this time.