Relative URL handling added to Response type.
This commit is contained in:
25
response.go
Normal file
25
response.go
Normal 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()
|
||||
}
|
Reference in New Issue
Block a user