mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 11:33:13 +00:00
💣 Fail fast if regular expression can not be initialized
This commit is contained in:
parent
a27cc68d2c
commit
6a12b3096f
1 changed files with 3 additions and 3 deletions
|
@ -12,11 +12,11 @@ import Version
|
|||
/// Manages searching the MAS catalog through the iTunes Search and Lookup APIs.
|
||||
class MasStoreSearch: StoreSearch {
|
||||
private let networkManager: NetworkManager
|
||||
private static let versionExpression: NSRegularExpression? = {
|
||||
private static let versionExpression: NSRegularExpression = {
|
||||
do {
|
||||
return try NSRegularExpression(pattern: #"\"versionDisplay\"\:\"([^\"]+)\""#)
|
||||
} catch {
|
||||
return nil
|
||||
fatalError("Unexpected error initializing NSRegularExpression: \(error.localizedDescription)")
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -125,7 +125,7 @@ class MasStoreSearch: StoreSearch {
|
|||
|
||||
let html = String(decoding: data, as: UTF8.self)
|
||||
let fullRange = NSRange(html.startIndex..<html.endIndex, in: html)
|
||||
guard let match = MasStoreSearch.versionExpression?.firstMatch(in: html, range: fullRange),
|
||||
guard let match = MasStoreSearch.versionExpression.firstMatch(in: html, range: fullRange),
|
||||
let range = Range(match.range(at: 1), in: html),
|
||||
let version = Version(tolerant: html[range])
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue