diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2019-12-01 09:44:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-01 09:44:21 +0100 |
commit | 6cccaebf64c62d314fb0fe70b36d24542541bf5c (patch) | |
tree | 4478ed218f6437cc4ea04ed4be839d7ce4deb0a9 /uri.go | |
parent | Allow a body for GET requests (#703) (diff) | |
download | fasthttp-6cccaebf64c62d314fb0fe70b36d24542541bf5c.tar.gz fasthttp-6cccaebf64c62d314fb0fe70b36d24542541bf5c.tar.bz2 fasthttp-6cccaebf64c62d314fb0fe70b36d24542541bf5c.zip |
Fix parsing relative URLs starting with // (#702)
* Fix parsing relative URLs starting with //
* Improve test
Diffstat (limited to 'uri.go')
-rw-r--r-- | uri.go | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -263,9 +263,14 @@ func (u *URI) Parse(host, uri []byte) { func (u *URI) parse(host, uri []byte, isTLS bool) { u.Reset() - scheme, host, uri := splitHostURI(host, uri) - u.scheme = append(u.scheme, scheme...) - lowercaseBytes(u.scheme) + if len(host) == 0 || bytes.Contains(uri, strColonSlashSlash) { + scheme, newHost, newURI := splitHostURI(host, uri) + u.scheme = append(u.scheme, scheme...) + lowercaseBytes(u.scheme) + host = newHost + uri = newURI + } + if isTLS { u.scheme = append(u.scheme[:0], strHTTPS...) } |