Skip to content

Commit f41b341

Browse files
committed
Merge pull request #22 from hyperoslo/feature/url-with-no-slash
Feature: URL with no slash
2 parents 905003b + e2759d7 commit f41b341

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

Source/Compass.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public struct Compass {
1717
var result = false
1818
let query = url.absoluteString.substringFromIndex(scheme.endIndex)
1919

20-
guard !(query.containsString("/?") || query.containsString("/#"))
20+
guard !(query.containsString("?") || query.containsString("#"))
2121
else { return parseAsURL(url, completion: completion) }
2222

2323
for route in routes.sort({ $0 < $1 }) {

Tests/TestCompass.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,26 @@ class TestCompass: XCTestCase {
9494
self.waitForExpectationsWithTimeout(4.0, handler:nil)
9595
}
9696

97+
func testParseRegularURLWithSlashQuery() {
98+
let expectation = self.expectationWithDescription("Parse URL with slash query")
99+
let url = NSURL(string: "compassTests://callback/?access_token=Yo0OMrVZbRWNmgA6BT99hyuTUTNRGvqEEAQyeN1eslclzhFD0M8AidB4Z7Vs2NU8WoSNW0vYb961O38l&token_type=Bearer&expires_in=3600")!
100+
101+
Compass.parse(url) { route, arguments in
102+
XCTAssertEqual(route, "callback")
103+
XCTAssertEqual(arguments.count, 3)
104+
XCTAssertEqual(arguments["access_token"], "Yo0OMrVZbRWNmgA6BT99hyuTUTNRGvqEEAQyeN1eslclzhFD0M8AidB4Z7Vs2NU8WoSNW0vYb961O38l")
105+
XCTAssertEqual(arguments["expires_in"], "3600")
106+
XCTAssertEqual(arguments["token_type"], "Bearer")
107+
108+
expectation.fulfill()
109+
}
110+
111+
self.waitForExpectationsWithTimeout(4.0, handler:nil)
112+
}
113+
97114
func testParseRegularURLWithQuery() {
98115
let expectation = self.expectationWithDescription("Parse URL with query")
99-
let url = NSURL(string: "compassTests://callback/?access_token=Yo0OMrVZbRWNmgA6BT99hyuTUTNRGvqEEAQyeN1eslclzhFD0M8AidB4Z7Vs2NU8WoSNW0vYb961O38l&token_type=Bearer&expires_in=3600")!
116+
let url = NSURL(string: "compassTests://callback?access_token=Yo0OMrVZbRWNmgA6BT99hyuTUTNRGvqEEAQyeN1eslclzhFD0M8AidB4Z7Vs2NU8WoSNW0vYb961O38l&token_type=Bearer&expires_in=3600")!
100117

101118
Compass.parse(url) { route, arguments in
102119
XCTAssertEqual(route, "callback")

0 commit comments

Comments
 (0)