Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit a7f9297

Browse files
committed
Check if a string is UUID using UUID.init(uuidString:)
1 parent 63f2fa3 commit a7f9297

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Tests/WordPressKitTests/Tests/Utilities/URLSessionHelperTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,9 @@ class URLSessionHelperTests: XCTestCase {
319319
// This functions finds temp files that are used for uploading multipart form.
320320
// The implementation relies on an internal implementation detail of building multipart form content.
321321
private func existingMultipartFormTempFiles() throws -> Set<String> {
322-
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}$")
323322
let fm = FileManager.default
324323
let files = try fm.contentsOfDirectory(atPath: fm.temporaryDirectory.path)
325-
.filter {
326-
uuidRegex.numberOfMatches(in: $0, range: NSMakeRange(0, $0.count)) == 1
327-
}
324+
.filter { UUID(uuidString: $0) != nil }
328325
return Set(files)
329326
}
330327

0 commit comments

Comments
 (0)