photoprism/pkg/txt/quote.go
2021-09-23 23:46:17 +02:00

20 lines
402 B
Go

package txt
import (
"fmt"
"strings"
)
// Quote adds quotation marks to a string if needed.
func Quote(text string) string {
if text == "" || strings.ContainsAny(text, " \n'\"") {
return fmt.Sprintf("“%s”", text)
}
return text
}
// QuoteLower converts a string to lowercase and adds quotation marks if needed.
func QuoteLower(text string) string {
return Quote(strings.ToLower(text))
}