-
Notifications
You must be signed in to change notification settings - Fork 0
/
entries.go
51 lines (42 loc) · 932 Bytes
/
entries.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package dvls
import (
"strconv"
"strings"
)
const (
entryEndpoint string = "/api/connections/partial"
entryConnectionsEndpoint string = "/api/connections"
)
type Entries struct {
Certificate *EntryCertificateService
Host *EntryHostService
UserCredential *EntryUserCredentialService
Website *EntryWebsiteService
}
func keywordsToSlice(kw string) []string {
var spacedTag bool
tags := strings.FieldsFunc(string(kw), func(r rune) bool {
if r == '"' {
spacedTag = !spacedTag
}
return !spacedTag && r == ' '
})
for i, v := range tags {
unquotedTag, err := strconv.Unquote(v)
if err != nil {
continue
}
tags[i] = unquotedTag
}
return tags
}
func sliceToKeywords(kw []string) string {
keywords := []string(kw)
for i, v := range keywords {
if strings.Contains(v, " ") {
kw[i] = "\"" + v + "\""
}
}
kString := strings.Join(keywords, " ")
return kString
}