2020-09-21 18:24:51 +00:00
|
|
|
package command
|
2020-02-02 23:05:18 +00:00
|
|
|
|
|
|
|
import (
|
2023-07-19 18:39:30 +00:00
|
|
|
"fmt"
|
2020-02-02 23:05:18 +00:00
|
|
|
"net/url"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
2023-07-19 18:39:30 +00:00
|
|
|
"github.com/thegeeklab/url-parser/config"
|
2020-02-02 23:05:18 +00:00
|
|
|
)
|
|
|
|
|
2020-02-03 11:44:19 +00:00
|
|
|
func parseURL(raw string) *url.URL {
|
|
|
|
urlString := strings.TrimSpace(raw)
|
2020-02-02 23:05:18 +00:00
|
|
|
|
|
|
|
url, err := url.Parse(urlString)
|
|
|
|
if err != nil {
|
2023-07-19 18:39:30 +00:00
|
|
|
logrus.Fatal(fmt.Errorf("%w: %w", config.ErrParseURL, err))
|
2020-02-02 23:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return url
|
|
|
|
}
|