github.com/gofunct/common@v0.0.0-20190131174352-fd058c7fbf22/pkg/strings/escape.go (about) 1 package strings 2 3 import ( 4 "strings" 5 ) 6 7 // EscapeQualifiedName converts a plugin name, which might contain a / into a 8 // string that is safe to use on-disk. This assumes that the input has already 9 // been validates as a qualified name. we use "~" rather than ":" here in case 10 // we ever use a filesystem that doesn't allow ":". 11 func EscapeQualifiedName(in string) string { 12 return strings.Replace(in, "/", "~", -1) 13 } 14 15 // UnescapeQualifiedName converts an escaped plugin name (as per EscapeQualifiedName) 16 // back to its normal form. This assumes that the input has already been 17 // validates as a qualified name. 18 func UnescapeQualifiedName(in string) string { 19 return strings.Replace(in, "~", "/", -1) 20 }