File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
library/src/main/kotlin/com/gabrielfeo/develocity/api/internal/auth Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,16 @@ internal class HostAccessKeyEntry(entry: String) {
6
6
7
7
init {
8
8
require(components.size == 2 && host.isNotBlank() && accessKey.isNotBlank()) {
9
- val redactedEntry = if (entry.length <= 5 ) entry else " ${entry.substring(0 , 4 )} [redacted]"
10
- " Invalid access key entry format: '$redactedEntry '. Expected format is 'host=accessKey'."
9
+ " Invalid access key entry format: '${redact(entry)} '. Expected format is 'host=accessKey'."
11
10
}
12
11
}
13
12
14
13
val host: String get() = components[0 ]
15
14
val accessKey: String get() = components[1 ]
16
- }
15
+ }
16
+
17
+ private const val REDACTED_MAX_LENGTH = 5
18
+
19
+ private fun redact (entry : String ): String =
20
+ if (entry.length <= REDACTED_MAX_LENGTH ) entry
21
+ else " ${entry.substring(0 , REDACTED_MAX_LENGTH - 1 )} [redacted]"
You can’t perform that action at this time.
0 commit comments