diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
index 842a78d1..a5d4f6d9 100644
--- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -7,7 +7,7 @@
AppShared.xcscheme_^#shared#^_
orderHint
- 27
+ 20
CoreDataStack.xcscheme_^#shared#^_
@@ -102,7 +102,7 @@
MastodonIntent.xcscheme_^#shared#^_
orderHint
- 28
+ 21
MastodonIntents.xcscheme_^#shared#^_
@@ -122,7 +122,7 @@
ShareActionExtension.xcscheme_^#shared#^_
orderHint
- 26
+ 19
SuppressBuildableAutocreation
diff --git a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved
index a1034488..11d45388 100644
--- a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -55,6 +55,15 @@
"version": "1.2.0"
}
},
+ {
+ "package": "FLAnimatedImage",
+ "repositoryURL": "https://github.com/Flipboard/FLAnimatedImage.git",
+ "state": {
+ "branch": null,
+ "revision": "e7f9fd4681ae41bf6f3056db08af4f401d61da52",
+ "version": "1.0.16"
+ }
+ },
{
"package": "FPSIndicator",
"repositoryURL": "https://github.com/MainasuK/FPSIndicator.git",
@@ -207,6 +216,15 @@
"revision": "d0470491f56e734731bbf77991944c0dfdee3e0e",
"version": "2.6.1"
}
+ },
+ {
+ "package": "UITextView+Placeholder",
+ "repositoryURL": "https://github.com/MainasuK/UITextView-Placeholder.git",
+ "state": {
+ "branch": null,
+ "revision": "20f513ded04a040cdf5467f0891849b1763ede3b",
+ "version": "1.4.1"
+ }
}
]
},
diff --git a/Mastodon/Info.plist b/Mastodon/Info.plist
index 11768d97..56eb9d83 100644
--- a/Mastodon/Info.plist
+++ b/Mastodon/Info.plist
@@ -2,6 +2,19 @@
+ NSAppTransportSecurity
+
+ NSExceptionDomains
+
+ onion
+
+ NSExceptionAllowsInsecureHTTPLoads
+
+ NSIncludesSubdomains
+
+
+
+
CADisableMinimumFrameDurationOnPhone
CFBundleDevelopmentRegion
diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift
index eb24f3a3..ee2ac8a0 100644
--- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift
+++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift
@@ -148,7 +148,7 @@ extension NotificationTimelineViewModel {
guard let authenticationBox = context.authenticationService.activeMastodonAuthenticationBox.value else { return }
isLoadingLatest = true
- defer{ isLoadingLatest = false }
+ defer { isLoadingLatest = false }
do {
_ = try await context.apiService.notifications(
diff --git a/Mastodon/Service/APIService/APIService+WebFinger.swift b/Mastodon/Service/APIService/APIService+WebFinger.swift
index 7cc0425d..b49ad9e3 100644
--- a/Mastodon/Service/APIService/APIService+WebFinger.swift
+++ b/Mastodon/Service/APIService/APIService+WebFinger.swift
@@ -16,7 +16,8 @@ import MastodonSDK
extension APIService {
private static func webFingerEndpointURL(domain: String) -> URL {
- return URL(string: "https://\(domain)/")!
+
+ return URL(string: "\(URL.httpScheme(domain: domain))://\(domain)/")!
.appendingPathComponent(".well-known")
.appendingPathComponent("webfinger")
}
diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift
index f72fd3af..66c822b3 100644
--- a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift
+++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift
@@ -74,27 +74,27 @@ extension Mastodon.API {
}()
static func oauthEndpointURL(domain: String) -> URL {
- return URL(string: "https://" + domain + "/oauth/")!
+ return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/oauth/")!
}
static func endpointURL(domain: String) -> URL {
- return URL(string: "https://" + domain + "/api/v1/")!
+ return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/api/v1/")!
}
static func endpointV2URL(domain: String) -> URL {
- return URL(string: "https://" + domain + "/api/v2/")!
+ return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/api/v2/")!
}
static let joinMastodonEndpointURL = URL(string: "https://api.joinmastodon.org/")!
public static func resendEmailURL(domain: String) -> URL {
- return URL(string: "https://" + domain + "/auth/confirmation/new")!
+ return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/auth/confirmation/new")!
}
public static func serverRulesURL(domain: String) -> URL {
- return URL(string: "https://" + domain + "/about/more")!
+ return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/about/more")!
}
public static func privacyURL(domain: String) -> URL {
- return URL(string: "https://" + domain + "/terms")!
+ return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/terms")!
}
}
diff --git a/MastodonSDK/Sources/MastodonSDK/Extension/URL.swift b/MastodonSDK/Sources/MastodonSDK/Extension/URL.swift
new file mode 100644
index 00000000..a9345c7b
--- /dev/null
+++ b/MastodonSDK/Sources/MastodonSDK/Extension/URL.swift
@@ -0,0 +1,14 @@
+//
+// URL.swift
+//
+//
+// Created by MainasuK on 2022-3-16.
+//
+
+import Foundation
+
+extension URL {
+ public static func httpScheme(domain: String) -> String {
+ return domain.hasSuffix(".onion") ? "http" : "https"
+ }
+}
diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift
index b14aad24..c1f09eb9 100644
--- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift
+++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+OAuthTests.swift
@@ -22,7 +22,7 @@ extension MastodonSDKTests {
os_log("%{public}s[%{public}ld], %{public}s: (%s) authorizeURL %s", ((#file as NSString).lastPathComponent), #line, #function, domain, authorizeURL.absoluteString)
XCTAssertEqual(
authorizeURL.absoluteString,
- "https://\(domain)/oauth/authorize?response_type=code&client_id=StubClientID&redirect_uri=mastodon://joinmastodon.org/oauth&scope=read%20write%20follow%20push"
+ "\(URL.httpScheme(domain: domain))://\(domain)/oauth/authorize?response_type=code&client_id=StubClientID&redirect_uri=mastodon://joinmastodon.org/oauth&scope=read%20write%20follow%20push"
)
}
diff --git a/MastodonTests/MastodonTests.swift b/MastodonTests/MastodonTests.swift
index 5da71aa4..7264dde6 100644
--- a/MastodonTests/MastodonTests.swift
+++ b/MastodonTests/MastodonTests.swift
@@ -8,6 +8,7 @@
import XCTest
@testable import Mastodon
+@MainActor
class MastodonTests: XCTestCase {
override func setUpWithError() throws {
@@ -43,4 +44,20 @@ extension MastodonTests {
}
wait(for: [expectation], timeout: 10)
}
+
+ @available(iOS 15.0, *)
+ func testConnectOnion() async throws {
+ let request = URLRequest(
+ url: URL(string: "http://a232ncr7jexk2chvubaq2v6qdizbocllqap7mnn7w7vrdutyvu32jeyd.onion/@k0gen")!,
+ cachePolicy: .reloadIgnoringLocalAndRemoteCacheData,
+ timeoutInterval: 10
+ )
+ do {
+ let data = try await URLSession.shared.data(for: request, delegate: nil)
+ print(data)
+ } catch {
+ debugPrint(error)
+ assertionFailure(error.localizedDescription)
+ }
+ }
}