From dfbca1540d875bb4e8fc96c3bb0ee38ac9276b57 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:52:41 -0700 Subject: [PATCH] Minor refactor for handling of LoggableDir (#3934) Reuse existing Elements code to conceal information. --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup #### Issue(s) * #3895 #### Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/pkg/path/elements.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/pkg/path/elements.go b/src/pkg/path/elements.go index 5a0802d50..838cea114 100644 --- a/src/pkg/path/elements.go +++ b/src/pkg/path/elements.go @@ -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() }