mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Conform URL to ExpressibleByStringLiteral (#1214)
This commit is contained in:
@@ -91,18 +91,18 @@ final class AppSettings {
|
|||||||
// MARK: - Authentication
|
// MARK: - Authentication
|
||||||
|
|
||||||
/// The URL that is opened when tapping the Learn more button on the sliding sync alert during authentication.
|
/// The URL that is opened when tapping the Learn more button on the sliding sync alert during authentication.
|
||||||
let slidingSyncLearnMoreURL = URL(staticString: "https://github.com/matrix-org/sliding-sync/blob/main/docs/Landing.md")
|
let slidingSyncLearnMoreURL: URL = "https://github.com/matrix-org/sliding-sync/blob/main/docs/Landing.md"
|
||||||
|
|
||||||
/// The redirect URL used for OIDC.
|
/// The redirect URL used for OIDC.
|
||||||
let oidcRedirectURL = URL(staticString: "io.element:/callback")
|
let oidcRedirectURL: URL = "io.element:/callback"
|
||||||
/// The app's main URL shown when using OIDC.
|
/// The app's main URL shown when using OIDC.
|
||||||
let oidcClientURL = URL(staticString: "https://element.io")
|
let oidcClientURL: URL = "https://element.io"
|
||||||
/// The app's Terms of Service URL shown when using OIDC.
|
/// The app's Terms of Service URL shown when using OIDC.
|
||||||
let oidcTermsURL = URL(staticString: "https://element.io/user-terms-of-service")
|
let oidcTermsURL: URL = "https://element.io/user-terms-of-service"
|
||||||
/// The app's Privacy Policy URL shown when using OIDC.
|
/// The app's Privacy Policy URL shown when using OIDC.
|
||||||
let oidcPolicyURL = URL(staticString: "https://element.io/privacy")
|
let oidcPolicyURL: URL = "https://element.io/privacy"
|
||||||
/// Any pre-defined static client registrations for OIDC issuers.
|
/// Any pre-defined static client registrations for OIDC issuers.
|
||||||
let oidcStaticRegistrations = [URL(staticString: "https://id.thirdroom.io/realms/thirdroom"): "elementx"]
|
let oidcStaticRegistrations: [URL: String] = ["https://id.thirdroom.io/realms/thirdroom": "elementx"]
|
||||||
|
|
||||||
// MARK: - Notifications
|
// MARK: - Notifications
|
||||||
|
|
||||||
@@ -114,12 +114,12 @@ final class AppSettings {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
let pushGatewayBaseURL = URL(staticString: "https://matrix.org/_matrix/push/v1/notify")
|
let pushGatewayBaseURL: URL = "https://matrix.org/_matrix/push/v1/notify"
|
||||||
|
|
||||||
// MARK: - Bug report
|
// MARK: - Bug report
|
||||||
|
|
||||||
let bugReportServiceBaseURL = URL(staticString: "https://riot.im/bugreports")
|
let bugReportServiceBaseURL: URL = "https://riot.im/bugreports"
|
||||||
let bugReportSentryURL = URL(staticString: "https://f39ac49e97714316965b777d9f3d6cd8@sentry.tools.element.io/44")
|
let bugReportSentryURL: URL = "https://f39ac49e97714316965b777d9f3d6cd8@sentry.tools.element.io/44"
|
||||||
// Use the name allocated by the bug report server
|
// Use the name allocated by the bug report server
|
||||||
let bugReportApplicationId = "element-x-ios"
|
let bugReportApplicationId = "element-x-ios"
|
||||||
let bugReportUISIId = "element-auto-uisi"
|
let bugReportUISIId = "element-auto-uisi"
|
||||||
@@ -134,7 +134,7 @@ final class AppSettings {
|
|||||||
let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element.elementx"),
|
let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element.elementx"),
|
||||||
host: "https://posthog.element.dev",
|
host: "https://posthog.element.dev",
|
||||||
apiKey: "phc_VtA1L35nw3aeAtHIx1ayrGdzGkss7k1xINeXcoIQzXN",
|
apiKey: "phc_VtA1L35nw3aeAtHIx1ayrGdzGkss7k1xINeXcoIQzXN",
|
||||||
termsURL: URL(staticString: "https://element.io/cookie-policy"))
|
termsURL: "https://element.io/cookie-policy")
|
||||||
#else
|
#else
|
||||||
/// The configuration to use for analytics. Set `isEnabled` to false to disable analytics.
|
/// The configuration to use for analytics. Set `isEnabled` to false to disable analytics.
|
||||||
/// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork, set custom configurations.
|
/// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork, set custom configurations.
|
||||||
@@ -171,7 +171,7 @@ final class AppSettings {
|
|||||||
|
|
||||||
// MARK: - Other
|
// MARK: - Other
|
||||||
|
|
||||||
let permalinkBaseURL = URL(staticString: "https://matrix.to")
|
let permalinkBaseURL: URL = "https://matrix.to"
|
||||||
|
|
||||||
// MARK: - Maps
|
// MARK: - Maps
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import Foundation
|
|||||||
extension UserProfileProxy {
|
extension UserProfileProxy {
|
||||||
// Mocks
|
// Mocks
|
||||||
static var mockAlice: UserProfileProxy {
|
static var mockAlice: UserProfileProxy {
|
||||||
.init(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: URL(staticString: "mxc://matrix.org/UcCimidcvpFvWkPzvjXMQPHA"))
|
.init(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: "mxc://matrix.org/UcCimidcvpFvWkPzvjXMQPHA")
|
||||||
}
|
}
|
||||||
|
|
||||||
static var mockBob: UserProfileProxy {
|
static var mockBob: UserProfileProxy {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
extension URL {
|
extension URL: ExpressibleByStringLiteral {
|
||||||
init(staticString: StaticString) {
|
public init(stringLiteral value: StaticString) {
|
||||||
guard let url = URL(string: "\(staticString)") else {
|
guard let url = URL(string: "\(value)") else {
|
||||||
fatalError("The static string used to create this URL is invalid")
|
fatalError("The static string used to create this URL is invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class MediaPreviewItem: NSObject, QLPreviewItem {
|
|||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
struct PreviewView_Previews: PreviewProvider {
|
struct PreviewView_Previews: PreviewProvider {
|
||||||
static let previewURL = URL(staticString: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")
|
static let previewURL: URL = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
|
||||||
static let previewItem = MediaPreviewItem(file: .unmanaged(url: previewURL),
|
static let previewItem = MediaPreviewItem(file: .unmanaged(url: previewURL),
|
||||||
title: "Important Document")
|
title: "Important Document")
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ struct TimelineReplyView_Previews: PreviewProvider {
|
|||||||
thumbnailSource: nil,
|
thumbnailSource: nil,
|
||||||
contentType: nil))))
|
contentType: nil))))
|
||||||
|
|
||||||
let imageSource = MediaSourceProxy(url: .init(staticString: "https://mock.com"), mimeType: "image/png")
|
let imageSource = MediaSourceProxy(url: "https://mock.com", mimeType: "image/png")
|
||||||
|
|
||||||
TimelineReplyView(placement: .timeline,
|
TimelineReplyView(placement: .timeline,
|
||||||
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Alice"),
|
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Alice"),
|
||||||
|
|||||||
+3
-3
@@ -24,13 +24,13 @@ struct LegalInformationScreen: View {
|
|||||||
Form {
|
Form {
|
||||||
Section {
|
Section {
|
||||||
Button(L10n.commonCopyright) {
|
Button(L10n.commonCopyright) {
|
||||||
openURL(URL(staticString: "https://element.io/copyright"))
|
openURL("https://element.io/copyright")
|
||||||
}
|
}
|
||||||
Button(L10n.commonAcceptableUsePolicy) {
|
Button(L10n.commonAcceptableUsePolicy) {
|
||||||
openURL(URL(staticString: "https://element.io/acceptable-use-policy-terms"))
|
openURL("https://element.io/acceptable-use-policy-terms")
|
||||||
}
|
}
|
||||||
Button(L10n.commonPrivacyPolicy) {
|
Button(L10n.commonPrivacyPolicy) {
|
||||||
openURL(URL(staticString: "https://element.io/privacy"))
|
openURL("https://element.io/privacy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.buttonStyle(.compoundForm(accessory: .navigationLink))
|
.buttonStyle(.compoundForm(accessory: .navigationLink))
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ struct OIDCAuthenticationDataProxy: Equatable {
|
|||||||
// var url: URL {
|
// var url: URL {
|
||||||
// URL(string: underlyingData.loginUrl())!
|
// URL(string: underlyingData.loginUrl())!
|
||||||
// }
|
// }
|
||||||
let url = URL(staticString: "https://theroadtonowhere")
|
let url: URL = "https://theroadtonowhere"
|
||||||
}
|
}
|
||||||
|
|
||||||
// extension OidcAuthenticationData: Equatable {
|
// extension OidcAuthenticationData: Equatable {
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class BugReportServiceTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testInitialStateWithRealService() throws {
|
func testInitialStateWithRealService() throws {
|
||||||
let service = BugReportService(withBaseURL: URL(staticString: "https://www.example.com"),
|
let service = BugReportService(withBaseURL: "https://www.example.com",
|
||||||
sentryURL: URL(staticString: "https://1234@sentry.com/1234"),
|
sentryURL: "https://1234@sentry.com/1234",
|
||||||
applicationId: "mock_app_id",
|
applicationId: "mock_app_id",
|
||||||
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
||||||
session: .mock)
|
session: .mock)
|
||||||
@@ -56,8 +56,8 @@ class BugReportServiceTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MainActor func testSubmitBugReportWithRealService() async throws {
|
@MainActor func testSubmitBugReportWithRealService() async throws {
|
||||||
let service = BugReportService(withBaseURL: URL(staticString: "https://www.example.com"),
|
let service = BugReportService(withBaseURL: "https://www.example.com",
|
||||||
sentryURL: URL(staticString: "https://1234@sentry.com/1234"),
|
sentryURL: "https://1234@sentry.com/1234",
|
||||||
applicationId: "mock_app_id",
|
applicationId: "mock_app_id",
|
||||||
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
||||||
session: .mock)
|
session: .mock)
|
||||||
|
|||||||
@@ -154,14 +154,14 @@ final class MediaProviderTests: XCTestCase {
|
|||||||
let expectedURL = URL(filePath: "/some/file/path")
|
let expectedURL = URL(filePath: "/some/file/path")
|
||||||
let expectedResult: Result<MediaFileHandleProxy, MediaProviderError> = .success(.unmanaged(url: expectedURL))
|
let expectedResult: Result<MediaFileHandleProxy, MediaProviderError> = .success(.unmanaged(url: expectedURL))
|
||||||
mediaLoader.mediaFileURL = expectedURL
|
mediaLoader.mediaFileURL = expectedURL
|
||||||
let result = await mediaProvider.loadFileFromSource(MediaSourceProxy(url: URL(staticString: "test/test1"), mimeType: "video/mp4"))
|
let result = await mediaProvider.loadFileFromSource(MediaSourceProxy(url: "test/test1", mimeType: "video/mp4"))
|
||||||
XCTAssertEqual(result, expectedResult)
|
XCTAssertEqual(result, expectedResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_whenLoadFileFromSourceAndNoFileFromSourceExistsAndLoadContentSourceFails_failureIsReturned() async throws {
|
func test_whenLoadFileFromSourceAndNoFileFromSourceExistsAndLoadContentSourceFails_failureIsReturned() async throws {
|
||||||
let expectedResult: Result<MediaFileHandleProxy, MediaProviderError> = .failure(.failedRetrievingFile)
|
let expectedResult: Result<MediaFileHandleProxy, MediaProviderError> = .failure(.failedRetrievingFile)
|
||||||
mediaLoader.mediaFileURL = nil
|
mediaLoader.mediaFileURL = nil
|
||||||
let result = await mediaProvider.loadFileFromSource(MediaSourceProxy(url: URL(staticString: "test/test1"), mimeType: "video/mp4"))
|
let result = await mediaProvider.loadFileFromSource(MediaSourceProxy(url: "test/test1", mimeType: "video/mp4"))
|
||||||
XCTAssertEqual(result, expectedResult)
|
XCTAssertEqual(result, expectedResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,19 +108,19 @@ class PermalinkBuilderTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testPermalinkDetection() {
|
func testPermalinkDetection() {
|
||||||
var url = URL(staticString: "https://www.matrix.org")
|
var url: URL = "https://www.matrix.org"
|
||||||
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), nil)
|
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), nil)
|
||||||
|
|
||||||
url = URL(staticString: "https://matrix.to/#/@bob:matrix.org?via=matrix.org")
|
url = "https://matrix.to/#/@bob:matrix.org?via=matrix.org"
|
||||||
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.userIdentifier("@bob:matrix.org"))
|
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.userIdentifier("@bob:matrix.org"))
|
||||||
|
|
||||||
url = URL(staticString: "https://matrix.to/#/!roomidentifier:matrix.org?via=matrix.org")
|
url = "https://matrix.to/#/!roomidentifier:matrix.org?via=matrix.org"
|
||||||
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.roomIdentifier("!roomidentifier:matrix.org"))
|
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.roomIdentifier("!roomidentifier:matrix.org"))
|
||||||
|
|
||||||
url = URL(staticString: "https://matrix.to/#/%23roomalias:matrix.org?via=matrix.org")
|
url = "https://matrix.to/#/%23roomalias:matrix.org?via=matrix.org"
|
||||||
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.roomAlias("#roomalias:matrix.org"))
|
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.roomAlias("#roomalias:matrix.org"))
|
||||||
|
|
||||||
url = URL(staticString: "https://matrix.to/#/!roomidentifier:matrix.org/$eventidentifier?via=matrix.org")
|
url = "https://matrix.to/#/!roomidentifier:matrix.org/$eventidentifier?via=matrix.org"
|
||||||
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.event(roomIdentifier: "!roomidentifier:matrix.org", eventIdentifier: "$eventidentifier"))
|
XCTAssertEqual(PermalinkBuilder.detectPermalink(in: url, baseURL: appSettings.permalinkBaseURL), PermalinkType.event(roomIdentifier: "!roomidentifier:matrix.org", eventIdentifier: "$eventidentifier"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user