aboutsummaryrefslogtreecommitdiff
path: root/internal/imap
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/imap/folder.go4
-rw-r--r--internal/imap/imap.go9
2 files changed, 6 insertions, 7 deletions
diff --git a/internal/imap/folder.go b/internal/imap/folder.go
index 9386293..32bfefe 100644
--- a/internal/imap/folder.go
+++ b/internal/imap/folder.go
@@ -7,6 +7,10 @@ type Folder struct {
delimiter string
}
+func (f Folder) IsBlank() bool {
+ return f.str == ""
+}
+
func (f Folder) String() string {
return f.str
}
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index 4a18a94..a44a513 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -2,7 +2,6 @@ package imap
import (
"fmt"
- "strings"
"github.com/Necoro/feed2imap-go/pkg/config"
"github.com/Necoro/feed2imap-go/pkg/log"
@@ -31,15 +30,11 @@ func Connect(url config.Url) (*Client, error) {
}
client.delimiter = delim
- toplevel := url.Root
- if toplevel[0] == '/' {
- toplevel = toplevel[1:]
- }
- client.toplevel = client.folderName(strings.Split(toplevel, "/"))
+ client.toplevel = client.folderName(url.RootPath())
log.Printf("Determined '%s' as toplevel, with '%s' as delimiter", client.toplevel, client.delimiter)
- if toplevel != "" {
+ if !client.toplevel.IsBlank() {
if err = conn.ensureFolder(client.toplevel); err != nil {
return nil, err
}