File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
src/core/plugins/json-schema-2020-12-samples/fn
test/unit/core/plugins/json-schema-2020-12-samples Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import encodeQuotedPrintable from "../encoders/quoted-printable"
99import encodeBase16 from "../encoders/base16"
1010import encodeBase32 from "../encoders/base32"
1111import encodeBase64 from "../encoders/base64"
12+ import encodeBase64Url from "../encoders/base64url"
1213
1314class EncoderRegistry extends Registry {
1415 #defaults = {
@@ -19,6 +20,7 @@ class EncoderRegistry extends Registry {
1920 base16 : encodeBase16 ,
2021 base32 : encodeBase32 ,
2122 base64 : encodeBase64 ,
23+ base64url : encodeBase64Url ,
2224 }
2325
2426 data = { ...this . #defaults }
Original file line number Diff line number Diff line change 1+ /**
2+ * @prettier
3+ */
4+ const encodeBase64Url = ( content ) => Buffer . from ( content ) . toString ( "base64url" )
5+
6+ export default encodeBase64Url
Original file line number Diff line number Diff line change @@ -138,6 +138,15 @@ describe("sampleFromSchema", () => {
138138 ) . toStrictEqual (
139139 "aHR0cHM6Ly9leGFtcGxlLmNvbS9kaWN0aW9uYXJ5L3t0ZXJtOjF9L3t0ZXJtfQ=="
140140 )
141+ expect (
142+ sample ( {
143+ type : "string" ,
144+ format : "uri-template" ,
145+ contentEncoding : "base64url" ,
146+ } )
147+ ) . toStrictEqual (
148+ "aHR0cHM6Ly9leGFtcGxlLmNvbS9kaWN0aW9uYXJ5L3t0ZXJtOjF9L3t0ZXJtfQ"
149+ )
141150 expect (
142151 sample ( {
143152 type : "string" ,
You can’t perform that action at this time.
0 commit comments