File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ describe('sanitization', () => {
8080 expect ( format ( query , [ state ] ) ) . toEqual ( expected )
8181 } )
8282
83+ test ( 'formats empty Uint8Array' , ( ) => {
84+ const query = 'select 1 from user where state = ?'
85+ const expected = "select 1 from user where state = x''"
86+ expect ( format ( query , [ new Uint8Array ( [ ] ) ] ) ) . toEqual ( expected )
87+ } )
88+
8389 test ( 'escapes double quotes' , ( ) => {
8490 const query = 'select 1 from user where state = ?'
8591 const expected = 'select 1 from user where state = \'\\"a\\"\''
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ describe('text', () => {
4242
4343 describe ( 'uint8ArrayToHex' , ( ) => {
4444 test ( 'converts an array of 8-bit unsigned integers to hex' , ( ) => {
45- expect ( uint8ArrayToHex ( new Uint8Array ( [ 197 ] ) ) ) . toEqual ( '0xc5' )
45+ expect ( uint8ArrayToHex ( new Uint8Array ( [ ] ) ) ) . toEqual ( "x''" )
46+ expect ( uint8ArrayToHex ( new Uint8Array ( [ 197 ] ) ) ) . toEqual ( "x'c5'" )
4647 } )
4748 } )
4849} )
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export function uint8Array(text: string): Uint8Array {
1515
1616export function uint8ArrayToHex ( uint8 : Uint8Array ) : string {
1717 const digits = Array . from ( uint8 ) . map ( ( i ) => i . toString ( 16 ) . padStart ( 2 , '0' ) )
18- return `0x ${ digits . join ( '' ) } `
18+ return `x' ${ digits . join ( '' ) } ' `
1919}
2020
2121function bytes ( text : string ) : number [ ] {
You can’t perform that action at this time.
0 commit comments