Skip to content

Commit 72b977e

Browse files
authored
Merge pull request #323 from KC-2001MS/fix/get-record-pds-routing
Use resolvePDSHost(for:) in getRepositoryRecord()
2 parents 883bbd2 + 866d3e7 commit 72b977e

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Sources/ATProtoKit/APIReference/ComAtprotoAPI/ComAtprotoRepoGetRecordMethod.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extension ATProtoKit {
2626
/// - collection: The Namespaced Identifier (NSID) of the record.
2727
/// - recordKey: The record key of the record.
2828
/// - recordCID: The CID hash of the record. Optional.
29+
/// - pdsURL: The URL of the Personal Data Server (PDS). Optional. Defaults to `nil`.
2930
/// - Returns: The record itself, as well as its URI and CID.
3031
///
3132
/// - Throws: An ``ATProtoError``-conforming error type, depending on the issue. Go to
@@ -34,9 +35,17 @@ extension ATProtoKit {
3435
from repository: String,
3536
collection: String,
3637
recordKey: String,
37-
recordCID: String? = nil
38+
recordCID: String? = nil,
39+
pdsURL: String? = nil
3840
) async throws -> ComAtprotoLexicon.Repository.GetRecordOutput {
39-
guard let requestURL = URL(string: "\(self.pdsURL)/xrpc/com.atproto.repo.getRecord") else {
41+
let host: String
42+
if let pdsURL, !pdsURL.isEmpty {
43+
host = pdsURL
44+
} else {
45+
host = await resolvePDSHost(for: repository)
46+
}
47+
48+
guard let requestURL = URL(string: "\(host)/xrpc/com.atproto.repo.getRecord") else {
4049
throw ATRequestPrepareError.invalidRequestURL
4150
}
4251

0 commit comments

Comments
 (0)