aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-08 08:42:11 +0800
committerRunxi Yu <me@runxiyu.org>2024-12-08 08:44:04 +0800
commitc6eacf7ef76fc2aa9a779618220b10ac0448fd6b (patch)
tree37cc76848049397c2320af0c28bbcfaa59d77290
parentAdd LICENSE (diff)
downloadmeseircd-c6eacf7ef76fc2aa9a779618220b10ac0448fd6b.tar.gz
meseircd-c6eacf7ef76fc2aa9a779618220b10ac0448fd6b.tar.zst
meseircd-c6eacf7ef76fc2aa9a779618220b10ac0448fd6b.zip
Slight refactor
-rw-r--r--Makefile4
-rw-r--r--go.mod2
-rw-r--r--msg.go9
-rw-r--r--tags.go7
-rw-r--r--util.go9
5 files changed, 16 insertions, 15 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..83d9213
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+# Only GNU Make is supported
+
+meseircd: *.go
+ go build -o $@
diff --git a/go.mod b/go.mod
index 5447113..6c5d231 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
module git.sr.ht/~runxiyu/meseircd
-go 1.23.3
+go 1.22
diff --git a/msg.go b/msg.go
index ff4b3a4..7e778f3 100644
--- a/msg.go
+++ b/msg.go
@@ -114,12 +114,3 @@ func parseIRCMsg(line string) (msg Msg, err error) {
return
}
-
-func isASCII(str string) bool {
- for i := 0; i < len(str); i++ {
- if str[i] > 127 {
- return false
- }
- }
- return true
-}
diff --git a/tags.go b/tags.go
index 43a2833..31f1154 100644
--- a/tags.go
+++ b/tags.go
@@ -32,7 +32,8 @@ func parseTags(tagsString string) (tags map[string]string, err error) {
// "Implementations [...] MUST NOT perform any validation that would
// reject the message if an invalid tag key name is used."
if validateTagName(tagName) {
- if !validateTagValue(tagValue) {
+ // "Tag values MUST be encoded as UTF8."
+ if !utf8.ValidString(tagValue) {
err = ErrInvalidTagContent
return
}
@@ -113,7 +114,3 @@ func validateTagName(name string) bool {
return true
}
-// "Tag values MUST be encoded as UTF8."
-func validateTagValue(value string) bool {
- return utf8.ValidString(value)
-}
diff --git a/util.go b/util.go
index 0037330..8754348 100644
--- a/util.go
+++ b/util.go
@@ -6,3 +6,12 @@ func trimInitialSpaces(line string) string {
}
return line[i:]
}
+
+func isASCII(str string) bool {
+ for i := 0; i < len(str); i++ {
+ if str[i] > 127 {
+ return false
+ }
+ }
+ return true
+}