Skip to content

Commit d0ed741

Browse files
committed
don't strip away slashes directly following scheme
1 parent e5fb2b8 commit d0ed741

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/URLMatcher.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ open class URLMatcher {
154154
///
155155
/// - Removing redundant trailing slash(/) on scheme
156156
/// - Removing redundant double-slashes(//)
157-
/// - Removing trailing slash(/)
157+
/// - Removing trailing slash(/) aside from slashes directly following the scheme
158158
///
159159
/// - parameter dirtyURL: The dirty URL to be normalized.
160160
///
@@ -167,7 +167,7 @@ open class URLMatcher {
167167
urlString = urlString.components(separatedBy: "?")[0].components(separatedBy: "#")[0]
168168
urlString = self.replaceRegex(":/{3,}", "://", urlString)
169169
urlString = self.replaceRegex("(?<!:)/{2,}", "/", urlString)
170-
urlString = self.replaceRegex("/+$", "", urlString)
170+
urlString = self.replaceRegex("(?<!:|:/)/+$", "", urlString)
171171
return urlString
172172
}
173173

Tests/URLNavigatorPublicTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class URLNavigatorPublicTests: XCTestCase {
6060
"Hello"
6161
)
6262

63-
XCTAssertNil(self.navigator.viewController(for: "http://"))
64-
XCTAssertNil(self.navigator.viewController(for: "https://"))
63+
XCTAssert(self.navigator.viewController(for: "http://") is WebViewController)
64+
XCTAssert(self.navigator.viewController(for: "https://") is WebViewController)
6565
XCTAssert(self.navigator.viewController(for: "http://xoul.kr") is WebViewController)
6666
XCTAssert(self.navigator.viewController(for: "http://xoul.kr/resume") is WebViewController)
6767
XCTAssert(self.navigator.viewController(for: "http://google.com/search?q=URLNavigator") is WebViewController)
@@ -155,8 +155,8 @@ class URLNavigatorPublicTests: XCTestCase {
155155
XCTAssert(self.navigator.viewController(for: "/post/123") is PostViewController)
156156
XCTAssert(self.navigator.viewController(for: "/post/hello-world") is PostViewController)
157157

158-
XCTAssertNil(self.navigator.viewController(for: "http://"))
159-
XCTAssertNil(self.navigator.viewController(for: "https://"))
158+
XCTAssert(self.navigator.viewController(for: "http://") is WebViewController)
159+
XCTAssert(self.navigator.viewController(for: "https://") is WebViewController)
160160
XCTAssert(self.navigator.viewController(for: "http://xoul.kr") is WebViewController)
161161
XCTAssert(self.navigator.viewController(for: "http://xoul.kr/resume") is WebViewController)
162162
XCTAssert(self.navigator.viewController(for: "http://google.com/search?q=URLNavigator") is WebViewController)

0 commit comments

Comments
 (0)