aboutsummaryrefslogtreecommitdiff
path: root/mailkit/addr.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-12 04:22:49 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-12 04:22:49 +0800
commit35d69905e2fc47c9b13e5d7e4ffbd0b6b277a76e (patch)
tree91fc4e1d5f378f1c24fe4b1756e6ecb46f887032 /mailkit/addr.go
parentmisc: Fix documentation of Pointerize_first (diff)
downloadgo-lindenii-common-35d69905e2fc47c9b13e5d7e4ffbd0b6b277a76e.tar.gz
go-lindenii-common-35d69905e2fc47c9b13e5d7e4ffbd0b6b277a76e.tar.zst
go-lindenii-common-35d69905e2fc47c9b13e5d7e4ffbd0b6b277a76e.zip
mailkit: Strip_angle_brackets
Diffstat (limited to '')
-rw-r--r--mailkit/addr.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/mailkit/addr.go b/mailkit/addr.go
new file mode 100644
index 0000000..c087be0
--- /dev/null
+++ b/mailkit/addr.go
@@ -0,0 +1,27 @@
+package mailkit
+
+// Strip_angle_brackets strips a single "<" from the
+// front of the string and a single ">" from the back
+// of the string. If either are present, stripped
+// returns true; if both are present, balanced also
+// returns true.
+func Strip_angle_brackets(x string) (result string, stripped bool, balanced bool) {
+ var tmp string
+ if x[0] == '<' {
+ tmp = x[1:]
+ stripped = true
+ } else {
+ tmp = x
+ }
+ if tmp[len(tmp)-1] == '>' {
+ result = tmp[:len(tmp)-1]
+ if stripped {
+ balanced = true
+ } else {
+ stripped = true
+ }
+ } else {
+ result = tmp
+ }
+ return
+}