This change should have no user impact. This makes the following changes to `OWSRequestFactory.reportSpam`: - Converts it to Swift - Adds tests - Handles a server GUID that couldn't be URL-encoded. For example, if it contained spaces, we'd crash constructing the URL. No longer! - Handles an empty server GUID
21 lines
573 B
Swift
21 lines
573 B
Swift
//
|
|
// Copyright 2023 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import XCTest
|
|
import SignalServiceKit
|
|
|
|
final class URLPathComponentsTest: XCTestCase {
|
|
func testNoComponents() {
|
|
XCTAssertNil(URL(pathComponents: []))
|
|
XCTAssertNil(URL(pathComponents: [""]))
|
|
XCTAssertNil(URL(pathComponents: ["", "", ""]))
|
|
}
|
|
|
|
func testFilteringAndEncodingComponents() {
|
|
let url = URL(pathComponents: ["foo", "", "~", "bar / baz?qúx"])!
|
|
XCTAssertEqual(url.relativeString, "foo/~/bar%20%2F%20baz%3Fq%C3%BAx")
|
|
}
|
|
}
|