Skip to content

Commit

Permalink
Adjust test, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dim13 committed Jul 21, 2021
1 parent 2181b29 commit f77dbc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions migration/cleanname.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package migration

import (
"path/filepath"
"os"
"strings"

"github.com/google/uuid"
Expand All @@ -10,11 +10,13 @@ import (
// FileName returns sanitized filename without path delimiters
func (op *Payload_OtpParameters) FileName() string {
return strings.Map(func(r rune) rune {
if r == filepath.Separator || r == filepath.PathListSeparator {
switch r {
case os.PathSeparator, os.PathListSeparator:
return '_'
default:
return r
}
return r
}, op.Name + "_" + op.Issuer)
}, op.Name+"_"+op.Issuer)
}

// UUID of OTP parameter
Expand Down
4 changes: 2 additions & 2 deletions migration/cleanname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func TestFileName(t *testing.T) {
Name: "A/B:C.d",
Issuer: "Issuer",
},
want: "A_B:C.d_Issuer",
want: "A_B_C.d_Issuer",
},
{
op: &Payload_OtpParameters{
Name: "A/../B:C.d",
Issuer: "Issuer",
},
want: "A_.._B:C.d_Issuer",
want: "A_.._B_C.d_Issuer",
},
}

Expand Down

0 comments on commit f77dbc0

Please sign in to comment.