Fixed issue with host string and added internal url package

This commit is contained in:
David Allen 2024-08-14 10:57:30 -06:00
parent 4444a1d299
commit 4597f63d12
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
7 changed files with 131 additions and 115 deletions

View file

@ -3,10 +3,10 @@ package cmd
import (
"fmt"
"os/user"
"strings"
magellan "github.com/OpenCHAMI/magellan/internal"
"github.com/OpenCHAMI/magellan/internal/cache/sqlite"
urlx "github.com/OpenCHAMI/magellan/internal/url"
"github.com/OpenCHAMI/magellan/pkg/auth"
"github.com/cznic/mathutil"
"github.com/rs/zerolog/log"
@ -33,8 +33,10 @@ var collectCmd = &cobra.Command{
}
// URL sanitanization for host argument
host = strings.TrimSuffix(host, "/")
host = strings.ReplaceAll(host, "//", "/")
host, err = urlx.Sanitize(host)
if err != nil {
log.Error().Err(err).Msg("failed to sanitize host")
}
// try to load access token either from env var, file, or config if var not set
if accessToken == "" {