stash/pkg/utils/url.go
WithoutPants f26766033e
Performer urls (#4958)
* Populate URLs from legacy fields
* Return nil properly in xpath/json scrapers
* Improve migration logging
2024-06-18 13:41:05 +10:00

15 lines
373 B
Go

package utils
import "regexp"
// URLFromHandle adds the site URL to the input if the input is not already a URL
// siteURL must not end with a slash
func URLFromHandle(input string, siteURL string) string {
// if the input is already a URL, return it
re := regexp.MustCompile(`^https?://`)
if re.MatchString(input) {
return input
}
return siteURL + "/" + input
}