File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Sources/XCLogParser/lexer Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public class LexRedactor: LogRedactor {
2323 private static let redactedTemplate = " /Users/<redacted>/ "
2424 private lazy var userDirRegex : NSRegularExpression ? = {
2525 do {
26- return try NSRegularExpression ( pattern: " \\ /Users \\ /( \\ w*) \\ / " )
26+ return try NSRegularExpression ( pattern: " /Users/([^/]+)/? " )
2727 } catch {
2828 return nil
2929 }
Original file line number Diff line number Diff line change @@ -25,14 +25,24 @@ class LexRedactorTests: XCTestCase {
2525 let redactor = LexRedactor ( )
2626
2727 func testRedacting( ) {
28-
2928 let redactedText = redactor. redactUserDir ( string: " Some /Users/private/path " )
3029
3130 XCTAssertEqual ( redactedText, " Some /Users/<redacted>/path " )
3231 }
3332
34- func testMultiplePathsRedacting( ) {
33+ func testRedactingComplexUsername( ) {
34+ let redactedText = redactor. redactUserDir ( string: " Some /Users/private-user/path " )
35+
36+ XCTAssertEqual ( redactedText, " Some /Users/<redacted>/path " )
37+ }
3538
39+ func testRedactingHomePath( ) {
40+ let redactedText = redactor. redactUserDir ( string: " /Users/private-user " )
41+
42+ XCTAssertEqual ( redactedText, " /Users/<redacted>/ " )
43+ }
44+
45+ func testMultiplePathsRedacting( ) {
3646 let redactedText = redactor. redactUserDir ( string: " Some /Users/private/path and other /Users/private/path2 " )
3747
3848 XCTAssertEqual ( redactedText, " Some /Users/<redacted>/path and other /Users/<redacted>/path2 " )
You can’t perform that action at this time.
0 commit comments