-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.go
More file actions
30 lines (24 loc) · 754 Bytes
/
utils.go
File metadata and controls
30 lines (24 loc) · 754 Bytes
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
// Copyright 2020 CleverGo. All rights reserved.
// Use of this source code is governed by a MIT style license that can be found
// in the LICENSE file.
package dnspodcn
import (
"strconv"
"strings"
"time"
)
// formatDomain removes the dot suffix of a domain.
func formatDomain(domain string) string {
if domain[len(domain)-1] == '.' {
return domain[:len(domain)-1]
}
return domain
}
// formatSubdomain removes the dot suffix and root domain of subdomain.
func formatSubdomain(domain, subdomain string) string {
return formatDomain(strings.TrimSuffix(formatDomain(subdomain), domain))
}
// formatTTL returns a string that represents the seconds of ttl.
func formatTTL(ttl time.Duration) string {
return strconv.Itoa(int(ttl.Seconds()))
}