diff --git a/README.md b/README.md
index d603b32..adc1e27 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-[](https://bsky.app/profile/cjrriley.com)
+[](https://bsky.app/profile/cjrriley.ca)
[](https://github.com/sponsors/MasterJ93)
@@ -156,7 +156,7 @@ You can also use this project for any programs you make using Swift and running
## Submitting Contributions and Feedback
While this project will change significantly, feedback, issues, and contributions are highly welcomed and encouraged. If you'd like to contribute to this project, please be sure to read both the [API Guidelines](https://github.com/ATProtoKit/MultiformatsKit/blob/main/API_GUIDELINES.md) as well as the [Contributor Guidelines](https://github.com/MasterJ93/ATProtoKit/blob/main/CONTRIBUTING.md) before submitting a pull request. Any issues (such as bug reports or feedback) can be submitted in the [Issues](https://github.com/ATProtoKit/MultiformatsKit/issues) tab. Finally, if there are any security vulnerabilities, please read [SECURITY.md](https://github.com/ATProtoKit/MultiformatsKit/blob/main/SECURITY.md) for how to report it.
-If you have any questions, you can ask me on Bluesky ([@cjrriley.com](https://bsky.app/profile/cjrriley.com)). And while you're at it, give me a follow! I'm also active on the [Bluesky API Touchers](https://discord.gg/3srmDsHSZJ) Discord server.
+If you have any questions, you can ask me on Bluesky ([@cjrriley.ca](https://bsky.app/profile/cjrriley.ca)). And while you're at it, give me a follow! I'm also active on the [Bluesky API Touchers](https://discord.gg/3srmDsHSZJ) Discord server.
## License
This Swift package is using the Apache 2.0 License. Please view [LICENSE.md](https://github.com/ATProtoKit/MultiformatsKit/blob/main/LICENSE.md) for more details.
diff --git a/Sources/MultiformatsKit/CID/CID.swift b/Sources/MultiformatsKit/CID/CID.swift
index 76a6e19..1bcb7c7 100644
--- a/Sources/MultiformatsKit/CID/CID.swift
+++ b/Sources/MultiformatsKit/CID/CID.swift
@@ -289,8 +289,28 @@ public struct CID: Codable, Sendable, Hashable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
- let cidString = try container.decode(String.self)
- self = try CID(string: cidString)
+ if let cidString = try? container.decode(String.self) {
+ self = try CID(string: cidString)
+ return
+ }
+
+ // Try decoding from a DAG-CBOR tagged value
+ if let bytes = try? container.decode(Data.self) {
+ guard bytes.first == 0x00 else {
+ throw DecodingError.dataCorrupted(.init(
+ codingPath: decoder.codingPath,
+ debugDescription: "DAG-CBOR CID must begin with '0x00'."
+ ))
+ }
+ let cidData = bytes.dropFirst()
+ self = try CID(rawData: Data(cidData))
+ return
+ }
+
+ throw DecodingError.dataCorrupted(.init(
+ codingPath: decoder.codingPath,
+ debugDescription: "Expected CID to be either a string or tagged DAG-CBOR CID."
+ ))
}
public func encode(to encoder: Encoder) throws {