From 72a329a68c69d2513cbff1ab0ef014e0955a9f5c Mon Sep 17 00:00:00 2001 From: RandomChars <random@chars.jp> Date: Sat, 2 Oct 2021 17:39:38 +0900 Subject: [PATCH] functions for the methods that shouldn't have been methods --- store/misc.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/store/misc.go b/store/misc.go index b72fa66..dd6ee40 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) +} -- GitLab