aboutsummaryrefslogtreecommitdiff
path: root/uri.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2019-12-01 09:44:21 +0100
committerGravatar GitHub <noreply@github.com> 2019-12-01 09:44:21 +0100
commit6cccaebf64c62d314fb0fe70b36d24542541bf5c (patch)
tree4478ed218f6437cc4ea04ed4be839d7ce4deb0a9 /uri.go
parentAllow a body for GET requests (#703) (diff)
downloadfasthttp-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.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/uri.go b/uri.go
index 21ab3ae..80e5bf3 100644
--- a/uri.go
+++ b/uri.go
@@ -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...)
}