1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 05:40:11 +01:00

Fix url handling
Some checks failed
Go / build (push) Has been cancelled
Go / run_modver (push) Has been cancelled

Check if relative URL is absolute.
This commit is contained in:
koplas 2025-07-17 12:04:04 +01:00
parent ae184eb189
commit 164d995aaf
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -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