mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 21:33:02 +01:00
* add label generation api * show location name on labels * add label scan page * dispose of code reader when navigating away from scan page * save label to png * implement code suggestions * fix label padding and margin * update swagger docs * add print from browser dialog Co-authored-by: fidoriel <49869342+fidoriel@users.noreply.github.com> * increase label description font weight * update documentation label file suffix * fix scanner components import * fix linting issues --------- Co-authored-by: fidoriel <49869342+fidoriel@users.noreply.github.com>
31 lines
594 B
Go
31 lines
594 B
Go
package v1
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func GetHBURL(refererHeader, fallback string) (hbURL string) {
|
|
hbURL = refererHeader
|
|
if hbURL == "" {
|
|
hbURL = fallback
|
|
}
|
|
|
|
return stripPathFromURL(hbURL)
|
|
}
|
|
|
|
// stripPathFromURL removes the path from a URL.
|
|
// ex. https://example.com/tools -> https://example.com
|
|
func stripPathFromURL(rawURL string) string {
|
|
parsedURL, err := url.Parse(rawURL)
|
|
if err != nil {
|
|
log.Err(err).Msg("failed to parse URL")
|
|
return ""
|
|
}
|
|
|
|
strippedURL := url.URL{Scheme: parsedURL.Scheme, Host: parsedURL.Host}
|
|
|
|
return strippedURL.String()
|
|
}
|