From b2630031191d4559ebbb7ad5cd634b8b144e51ec Mon Sep 17 00:00:00 2001 From: KitsuneSemCalda Date: Fri, 29 Mar 2024 10:44:34 -0300 Subject: [PATCH] fix: adding Episode Structure validation --- Structure/Episode.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Structure/Episode.go b/Structure/Episode.go index d234738..7f5142d 100644 --- a/Structure/Episode.go +++ b/Structure/Episode.go @@ -1,6 +1,9 @@ package structure -import "errors" +import ( + "errors" + "net/url" +) type Episode struct { Number int @@ -8,6 +11,8 @@ type Episode struct { } func IsValidEpisode(episode Episode) bool { + var err error + if episode.Number <= 0 { return false } @@ -16,7 +21,9 @@ func IsValidEpisode(episode Episode) bool { return false } - return true + _, err = url.ParseRequestURI(episode.Url) + + return err == nil } func NewEpisode(number int, url string) (*Episode, error) {