File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,15 @@ extension DataProtocol {
19
19
func base64URLEncodedString( ) -> String {
20
20
Data ( self )
21
21
. base64EncodedString ( )
22
- . replacingOccurrences ( of: " + " , with: " - " )
22
+ . transformToBase64URLEncoding ( )
23
+ }
24
+ }
25
+
26
+ extension String {
27
+ /// Transform a regular Base64 encoded string to a Base64URL encoded one.
28
+ @usableFromInline
29
+ func transformToBase64URLEncoding( ) -> String {
30
+ self . replacingOccurrences ( of: " + " , with: " - " )
23
31
. replacingOccurrences ( of: " / " , with: " _ " )
24
32
. replacingOccurrences ( of: " = " , with: " " )
25
33
}
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ extension VAPID.Key: Identifiable {
86
86
87
87
public init ( from decoder: any Decoder ) throws {
88
88
let container = try decoder. singleValueContainer ( )
89
- self . rawValue = try container. decode ( String . self)
89
+ self . rawValue = try container. decode ( String . self) . transformToBase64URLEncoding ( )
90
90
}
91
91
92
92
public func encode( to encoder: any Encoder ) throws {
You can’t perform that action at this time.
0 commit comments