Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2539: Super Referrer Improvements (Clipboard) #2535

Merged
merged 16 commits into from May 25, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Added path components helper to avoid manually adding forward slashes.

  • Loading branch information
jhreis committed May 18, 2020
commit 16d5037c3d3bf27581b4efa39cce6ca6d978ce91
@@ -52,8 +52,7 @@ struct UrpService {
params[UrpService.ParamKeys.platform] = "ios"
lastPathComponent = "nonua"
}

endPoint.appendPathComponent("promo/initialize/\(lastPathComponent)")
endPoint.append(pathComponents: "promo", "initialize", lastPathComponent)

sessionManager.urpApiRequest(endPoint: endPoint, params: params) { response in
switch response {
@@ -79,7 +78,7 @@ struct UrpService {
completion(nil, .endpointError)
return
}
endPoint.appendPathComponent("promo/activity")
endPoint.append(pathComponents: "promo", "activity")

let params = [
UrpService.ParamKeys.api: apiKey,
@@ -105,7 +104,7 @@ struct UrpService {
completion([], .endpointError)
return
}
endPoint.appendPathComponent("promo/custom-headers")
endPoint.append(pathComponents: "promo", "custom-headers")

let params = [UrpService.ParamKeys.api: apiKey]

@@ -82,6 +82,12 @@ extension URL {
}
return val
}

mutating public func append(pathComponents: String...) {
pathComponents.forEach {
self.appendPathComponent($0)
}
}

public func getResourceLongLongForKey(_ key: String) -> Int64? {
return (getResourceValueForKey(key) as? NSNumber)?.int64Value
@@ -476,6 +476,21 @@ class NSURLExtensionsTests: XCTestCase {
XCTAssertEqual("http://bar.com/noo?qqq=123", urlD.absoluteString)
XCTAssertEqual("http://foo.com/bar/?ppp=123&rrr=aaa", urlE.absoluteString)
}

func testAppendPathComponentsHelper() {
var urlA = URL(string: "http://foo.com/bar/")!
var urlB = URL(string: "http://bar.com/noo")!

urlA.append(pathComponents: "foo")
urlA.append(pathComponents: "one", "two")

urlB.append(pathComponents: "", "", "test", "", "one", "")

XCTAssertEqual("http://foo.com/bar/foo/one/two", urlA.absoluteString)
XCTAssertEqual("http://bar.com/noo/test/one/", urlB.absoluteString)


}

func testHidingFromDataDetectors() {
guard let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.