mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Fix url handling
Check if relative URL is absolute.
This commit is contained in:
parent
ae184eb189
commit
164d995aaf
2 changed files with 7 additions and 2 deletions
|
|
@ -12,6 +12,10 @@ import "net/url"
|
|||
|
||||
// JoinURL joins the two URLs while preserving the query and fragment part of the latter.
|
||||
func JoinURL(baseURL *url.URL, relativeURL *url.URL) *url.URL {
|
||||
// Check if we already have an absolute url
|
||||
if relativeURL.Host != "" && relativeURL.Host != baseURL.Host && relativeURL.Scheme == "https" {
|
||||
return relativeURL
|
||||
}
|
||||
u := baseURL.JoinPath(relativeURL.Path)
|
||||
u.RawQuery = relativeURL.RawQuery
|
||||
u.RawFragment = relativeURL.RawFragment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue