Skip to content

Commit

Permalink
Merge pull request #40 from mapbox/1ec5-mime-826
Browse files Browse the repository at this point in the history
Don’t even try to deserialize non-JSON response data
  • Loading branch information
1ec5 authored Oct 28, 2016
2 parents d6f162b + 0ce88ca commit 9294ff9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions MapboxStatic/Snapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,13 @@ public class Snapshot: NSObject {
var json: JSONDictionary = [:]
var image: Image?
if let data = data {
do {
json = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? JSONDictionary ?? json
} catch {
if response?.MIMEType == "application/json" {
do {
json = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? JSONDictionary ?? json
} catch {
assert(false, "Invalid data")
}
} else {
image = Image(data: data)
}
}
Expand Down

0 comments on commit 9294ff9

Please sign in to comment.