File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,14 @@ describe('urlsafe_b64encode', () => {
55 it ( 'should encode a string to base64' , ( ) => {
66 expect ( urlsafe_b64encode ( 'hello+foo/bar=====' ) ) . toBe ( 'aGVsbG8rZm9vL2Jhcj09PT09' ) ;
77 } ) ;
8- it ( 'multiple characters should be encoded correctly' , ( ) => {
9- // XXX: investigate how to produce a string that contains + or / when b64 encoded.
8+ it ( 'multiple + characters should be encoded correctly -' , ( ) => {
9+ let inp = 'const is_greater_than_1 = 45 >= 5 ? true : false\nconst is_greater_than_2 = 6435 >= 5 ? true : false' ;
10+ let expected = 'Y29uc3QgaXNfZ3JlYXRlcl90aGFuXzEgPSA0NSA-PSA1ID8gdHJ1ZSA6IGZhbHNlCmNvbnN0IGlzX2dyZWF0ZXJfdGhhbl8yID0gNjQzNSA-PSA1ID8gdHJ1ZSA6IGZhbHNl'
11+ expect ( urlsafe_b64encode ( inp ) ) . toBe ( expected ) ;
12+ } ) ;
13+ it ( 'multiple / characters should be encoded correctly as _' , ( ) => {
14+ let inp = 'const has_env1 = window.env1 ? true : false;\nconst has_env2 = window.env2 ? true : false;' ;
15+ let expected = 'Y29uc3QgaGFzX2VudjEgPSB3aW5kb3cuZW52MSA_IHRydWUgOiBmYWxzZTsKY29uc3QgaGFzX2VudjIgPSB3aW5kb3cuZW52MiA_IHRydWUgOiBmYWxzZTs'
16+ expect ( urlsafe_b64encode ( inp ) ) . toBe ( expected ) ;
1017 } ) ;
1118} ) ;
You can’t perform that action at this time.
0 commit comments