url-parser/command/commands.go

22 lines
338 B
Go
Raw Normal View History

2020-09-21 18:24:51 +00:00
package command
2020-02-02 23:05:18 +00:00
import (
"fmt"
2020-02-02 23:05:18 +00:00
"net/url"
"strings"
"github.com/sirupsen/logrus"
"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 {
logrus.Fatal(fmt.Errorf("%w: %w", config.ErrParseURL, err))
2020-02-02 23:05:18 +00:00
}
return url
}