Minor refactor for handling of LoggableDir (#3934)

Reuse existing Elements code to conceal information.

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #3895

#### Test Plan

- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-07-31 12:52:41 -07:00 committed by GitHub
parent f0425a0f9d
commit dfbca1540d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,6 @@ package path
import (
"fmt"
"strings"
"github.com/alcionai/clues"
@ -119,16 +118,8 @@ func (el Elements) Last() string {
// LoggableDir takes in a path reference (of any structure) and conceals any
// non-standard elements (ids, filenames, foldernames, etc).
func LoggableDir(ref string) string {
r := ref
n := strings.TrimSuffix(r, string(PathSeparator))
for n != r {
r = n
n = strings.TrimSuffix(r, string(PathSeparator))
}
elems := Split(r)
elems = pii.ConcealElements(elems, piiSafePathElems)
return join(elems)
// Can't directly use Builder since that could return an error. Instead split
// into elements and use that.
split := Split(TrimTrailingSlash(ref))
return Elements(split).Conceal()
}