github.com/blend/go-sdk@v1.20220411.3/sanitize/path_uuids.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package sanitize 9 10 import ( 11 "strings" 12 13 "github.com/blend/go-sdk/uuid" 14 ) 15 16 var ( 17 _ PathSanitizerFunc = PathUUIDs 18 ) 19 20 // PathUUIDs is a path sanitizer func 21 // that replaces any uuids in a path with "?". 22 func PathUUIDs(path string) string { 23 if path == "" || path == "/" { 24 return path 25 } 26 27 pathParts := strings.Split(path, "/") 28 for index := range pathParts { 29 if id, _ := uuid.Parse(pathParts[index]); !id.IsZero() { 30 pathParts[index] = "?" 31 } 32 } 33 return strings.Join(pathParts, "/") 34 }