mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
REFACTOR: Opinion: TXT records are one long string (#2631)
Co-authored-by: Costas Drogos <costas.drogos@gmail.com> Co-authored-by: imlonghao <git@imlonghao.com> Co-authored-by: Jeffrey Cafferata <jeffrey@jcid.nl> Co-authored-by: Vincent Hagen <blackshadev@users.noreply.github.com>
This commit is contained in:
@@ -7,8 +7,12 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// IsQuoted returns true if the string starts and ends with a double quote.
|
||||
func IsQuoted(s string) bool {
|
||||
/*
|
||||
TODO(tlim): Move this file to pkgs/txtutil. It doesn't need to be part
|
||||
*/
|
||||
|
||||
// isQuoted returns true if the string starts and ends with a double quote.
|
||||
func isQuoted(s string) bool {
|
||||
if s == "" {
|
||||
return false
|
||||
}
|
||||
@@ -24,7 +28,7 @@ func IsQuoted(s string) bool {
|
||||
// StripQuotes returns the string with the starting and ending quotes removed.
|
||||
// If it is not quoted, the original string is returned.
|
||||
func StripQuotes(s string) string {
|
||||
if IsQuoted(s) {
|
||||
if isQuoted(s) {
|
||||
return s[1 : len(s)-1]
|
||||
}
|
||||
return s
|
||||
@@ -41,7 +45,7 @@ func StripQuotes(s string) string {
|
||||
// NOTE: This doesn't handle escaped quotes.
|
||||
// NOTE: You probably want to use ParseQuotedFields() for RFC 1035-compliant quoting.
|
||||
func ParseQuotedTxt(s string) []string {
|
||||
if !IsQuoted(s) {
|
||||
if !isQuoted(s) {
|
||||
return []string{s}
|
||||
}
|
||||
return strings.Split(StripQuotes(s), `" "`)
|
||||
|
Reference in New Issue
Block a user