Relative URL handling added to Response type.

This commit is contained in:
Musab Gültekin
2019-06-07 15:44:14 +03:00
parent 944bd3bada
commit e58b08cbd6
4 changed files with 39 additions and 7 deletions

25
response.go Normal file
View File

@ -0,0 +1,25 @@
package gezer
import (
"github.com/PuerkitoBio/goquery"
"net/http"
"net/url"
)
type Response struct {
*http.Response
Body []byte
Doc *goquery.Document
Gezer *Gezer
}
func (r *Response) JoinURL(relativeURL string) string {
parsedRelativeURL, err := url.Parse(relativeURL)
if err != nil {
return ""
}
joinedURL := r.Response.Request.URL.ResolveReference(parsedRelativeURL)
return joinedURL.String()
}