Skip to content

Commit

Permalink
Check if a string is UUID using UUID.init(uuidString:)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli committed Apr 8, 2024
1 parent 63f2fa3 commit a7f9297
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,9 @@ class URLSessionHelperTests: XCTestCase {
// This functions finds temp files that are used for uploading multipart form.
// The implementation relies on an internal implementation detail of building multipart form content.
private func existingMultipartFormTempFiles() throws -> Set<String> {
let uuidRegex = try NSRegularExpression(pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$")
let fm = FileManager.default
let files = try fm.contentsOfDirectory(atPath: fm.temporaryDirectory.path)
.filter {
uuidRegex.numberOfMatches(in: $0, range: NSMakeRange(0, $0.count)) == 1
}
.filter { UUID(uuidString: $0) != nil }
return Set(files)
}

Expand Down

0 comments on commit a7f9297

Please sign in to comment.