Skip to content

Commit

Permalink
[fix] credential issuer id fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsiflit committed Oct 31, 2024
1 parent 5483f37 commit 83fa4fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Entities/CredentialIssuer/CredentialIssuerId.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public struct CredentialIssuerId: Codable, Equatable {
public init(_ string: String) throws {
if let queryItems = URLComponents(string: string)?.queryItems,
queryItems.count > 0 {
throw CredentialError.genericError
throw CredentialError.extraneousQueryComponents
}

guard
let validURL = URL(string: string),
validURL.scheme == "https",
validURL.fragment == nil
else {
throw CredentialError.genericError
throw CredentialError.invalidScheme
}

self.url = validURL
Expand All @@ -43,6 +43,6 @@ public struct CredentialIssuerId: Codable, Equatable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let urlString = try container.decode(String.self)
url = try URL(string: urlString) ?? { throw ValidationError.error(reason: "Invalid credential_issuer URL")}()
try self.init(urlString)
}
}
2 changes: 2 additions & 0 deletions Sources/Entities/Errors/CredentialError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ import Foundation
public enum CredentialError: Error {
case genericError
case issuerDoesNotSupportDeferredIssuance
case extraneousQueryComponents
case invalidScheme
}

0 comments on commit 83fa4fb

Please sign in to comment.