diff --git a/store/misc.go b/store/misc.go index b72fa66de57293797eeacc73b8fae7069d69144d..dd6ee40d32b0e4b3765cbc8584f1255ceac7b25a 100644 --- a/store/misc.go +++ b/store/misc.go @@ -19,15 +19,25 @@ var ( AlreadyExists = errors.New("store path already exists") ) -// These two really shouldn't be methods... Maybe change that for v2. - // MatchName determines if str is a valid name. -func (s *Store) MatchName(str string) bool { +func MatchName(str string) bool { return nameRegex.MatchString(str) } // MatchURL determines if str is a valid URL. -func (s *Store) MatchURL(str string) bool { +func MatchURL(str string) bool { u, err := url.Parse(str) return err == nil && u.Scheme != "" && u.Host != "" } + +// These two really shouldn't be methods... Maybe change that for v2. + +// MatchName determines if str is a valid name. As of v1, this just calls MatchName. +func (s *Store) MatchName(str string) bool { + return MatchName(str) +} + +// MatchURL determines if str is a valid URL. As of v1, this just calls MatchURL. +func (s *Store) MatchURL(str string) bool { + return MatchURL(str) +}