Skip to content

Commit 1c82133

Browse files
authored
Merge pull request #75 from mapbox/1ec5-mr-mime-type
Accept application/vnd.geo+json MIME type
2 parents 605d9ff + f255788 commit 1c82133

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

MapboxGeocoder/MBGeocoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public class Geocoder: NSObject {
227227
request.setValue(userAgent, forHTTPHeaderField: "User-Agent")
228228
return NSURLSession.sharedSession().dataTaskWithRequest(request) { (data, response, error) in
229229
var json: JSONDictionary = [:]
230-
if let data = data where response?.MIMEType == "application/json" {
230+
if let data = data, mimeType = response?.MIMEType where mimeType == "application/json" || mimeType == "application/vnd.geo+json" {
231231
do {
232232
json = try NSJSONSerialization.JSONObjectWithData(data, options: []) as! JSONDictionary
233233
} catch {

MapboxGeocoderTests/ForwardGeocodingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ForwardGeocodingTests: XCTestCase {
1616
&& isPath("/geocoding/v5/mapbox.places/1600+pennsylvania+ave.json")
1717
&& containsQueryParams(["country": "ca", "access_token": BogusToken])) { _ in
1818
let path = NSBundle(forClass: self.dynamicType).pathForResource("forward_valid", ofType: "json")
19-
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"])
19+
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/vnd.geo+json"])
2020
}
2121

2222
let geocoder = Geocoder(accessToken: BogusToken)
@@ -70,7 +70,7 @@ class ForwardGeocodingTests: XCTestCase {
7070
&& isPath("/geocoding/v5/mapbox.places/Sandy+Island,+New+Caledonia.json")
7171
&& containsQueryParams(["country": "nc", "types": "region,place,locality,poi", "access_token": BogusToken])) { _ in
7272
let path = NSBundle(forClass: self.dynamicType).pathForResource("forward_invalid", ofType: "json")
73-
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"])
73+
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/vnd.geo+json"])
7474
}
7575

7676
let expection = expectationWithDescription("forward geocode execute completion handler for invalid query")

MapboxGeocoderTests/ReverseGeocodingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ReverseGeocodingTests: XCTestCase {
1616
&& isPath("/geocoding/v5/mapbox.places/-95.78558,37.13284.json")
1717
&& containsQueryParams(["access_token": BogusToken])) { _ in
1818
let path = NSBundle(forClass: self.dynamicType).pathForResource("reverse_valid", ofType: "json")
19-
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"])
19+
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/vnd.geo+json"])
2020
}
2121

2222
let geocoder = Geocoder(accessToken: BogusToken)
@@ -76,7 +76,7 @@ class ReverseGeocodingTests: XCTestCase {
7676
&& isPath("/geocoding/v5/mapbox.places/0.00000,0.00000.json")
7777
&& containsQueryParams(["access_token": BogusToken])) { _ in
7878
let path = NSBundle(forClass: self.dynamicType).pathForResource("reverse_invalid", ofType: "json")
79-
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/json"])
79+
return OHHTTPStubsResponse(fileAtPath: path!, statusCode: 200, headers: ["Content-Type": "application/vnd.geo+json"])
8080
}
8181

8282
let expection = expectationWithDescription("reverse geocode execute completion handler for invalid query")

0 commit comments

Comments
 (0)