We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 42bc272 commit 1de030fCopy full SHA for 1de030f
jsonbytes/unpadded.go
@@ -28,3 +28,21 @@ func (b *UnpaddedBytes) UnmarshalJSON(data []byte) error {
28
*b, err = base64.RawStdEncoding.DecodeString(b64str)
29
return err
30
}
31
+
32
+// UnpaddedURLBytes is a byte slice that is encoded and decoded using
33
+// [base64.RawURLEncoding] instead of the default padded base64.
34
+type UnpaddedURLBytes []byte
35
36
+func (b UnpaddedURLBytes) MarshalJSON() ([]byte, error) {
37
+ return json.Marshal(base64.RawURLEncoding.EncodeToString(b))
38
+}
39
40
+func (b *UnpaddedURLBytes) UnmarshalJSON(data []byte) error {
41
+ var b64str string
42
+ err := json.Unmarshal(data, &b64str)
43
+ if err != nil {
44
+ return err
45
+ }
46
+ *b, err = base64.RawURLEncoding.DecodeString(b64str)
47
48
0 commit comments