Create isValidMediaType and isValidLanguageTag
This commit is contained in:
parent
39bd0776c5
commit
4fe133a394
12
atom.go
12
atom.go
@ -4,6 +4,8 @@ import (
|
||||
"mime"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -66,3 +68,13 @@ func isXMLMediaType(mediaType string) bool {
|
||||
|
||||
return strings.HasSuffix(mediaType, "/xml") || strings.HasSuffix(mediaType, "+xml")
|
||||
}
|
||||
|
||||
func isValidMediaType(mediaType string) bool {
|
||||
_, _, err := mime.ParseMediaType(mediaType)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func isValidLanguageTag(tag LanguageTag) bool {
|
||||
_, err := language.Parse(string(tag))
|
||||
return err == nil
|
||||
}
|
||||
|
5
go.mod
5
go.mod
@ -2,4 +2,7 @@ module streifling.com/jason/atom-feed
|
||||
|
||||
go 1.23.2
|
||||
|
||||
require github.com/google/uuid v1.6.0
|
||||
require (
|
||||
github.com/google/uuid v1.6.0
|
||||
golang.org/x/text v0.19.0
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -1,2 +1,4 @@
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
|
Loading…
x
Reference in New Issue
Block a user