Skip to content

Commit 1a829a4

Browse files
committed
refactor: Don't provide blank options
1 parent 28fc53d commit 1a829a4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sources/JWT/Base64.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import Foundation
22

33
/// URI Safe base64 encode
44
func base64encode(_ input: Data) -> String {
5-
let data = input.base64EncodedData(options: NSData.Base64EncodingOptions(rawValue: 0))
5+
let data = input.base64EncodedData()
66
let string = String(data: data, encoding: .utf8)!
77
return string
8-
.replacingOccurrences(of: "+", with: "-", options: NSString.CompareOptions(rawValue: 0), range: nil)
9-
.replacingOccurrences(of: "/", with: "_", options: NSString.CompareOptions(rawValue: 0), range: nil)
10-
.replacingOccurrences(of: "=", with: "", options: NSString.CompareOptions(rawValue: 0), range: nil)
8+
.replacingOccurrences(of: "+", with: "-")
9+
.replacingOccurrences(of: "/", with: "_")
10+
.replacingOccurrences(of: "=", with: "")
1111
}
1212

1313
/// URI Safe base64 decode
@@ -20,8 +20,8 @@ func base64decode(_ input: String) -> Data? {
2020
ending = String(repeating: "=", count: amount)
2121
}
2222

23-
let base64 = input.replacingOccurrences(of: "-", with: "+", options: NSString.CompareOptions(rawValue: 0), range: nil)
24-
.replacingOccurrences(of: "_", with: "/", options: NSString.CompareOptions(rawValue: 0), range: nil) + ending
23+
let base64 = input.replacingOccurrences(of: "-", with: "+")
24+
.replacingOccurrences(of: "_", with: "/") + ending
2525

26-
return Data(base64Encoded: base64, options: NSData.Base64DecodingOptions(rawValue: 0))
26+
return Data(base64Encoded: base64)
2727
}

0 commit comments

Comments
 (0)