We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9d1041e commit 52e2906Copy full SHA for 52e2906
utils/utils.go
@@ -0,0 +1,9 @@
1
+package utils
2
+
3
+import "strings"
4
5
+func Redact(token string) string {
6
+ str := token[4 : len(token)-3]
7
+ redaction := strings.Repeat("*", len(str))
8
+ return string(token[:4]) + redaction + string(token[len(token)-3:])
9
+}
utils/utils_test.go
@@ -0,0 +1,15 @@
+import (
+ "testing"
+ "github.com/exercism/cli/utils"
+ "github.com/stretchr/testify/assert"
+)
10
+func TestRedact(t *testing.T) {
11
+ fakeToken := "1a11111aaaa111aa1a11111a11111aa1"
12
+ expected := "1a11*************************aa1"
13
14
+ assert.Equal(t, expected, utils.Redact(fakeToken))
15
0 commit comments