@@ -25,4 +25,46 @@ describe('unwrapHtml', () => {
2525 'There was a problem extracting the TDF3 payload'
2626 ) ;
2727 } ) ;
28+
29+ describe ( 'regex pattern variations' , ( ) => {
30+ it ( 'should handle double quotes' , ( ) => {
31+ const htmlPayload = new TextEncoder ( ) . encode (
32+ '<input id="data-input" type="hidden" value="SGVsbG8gV29ybGQ=">'
33+ ) ;
34+ const result = unwrapHtml ( htmlPayload ) ;
35+ expect ( new TextDecoder ( ) . decode ( result ) ) . to . equal ( 'Hello World' ) ;
36+ } ) ;
37+
38+ it ( 'should handle single quotes' , ( ) => {
39+ const htmlPayload = new TextEncoder ( ) . encode (
40+ "<input id='data-input' type='hidden' value='SGVsbG8gV29ybGQ='>"
41+ ) ;
42+ const result = unwrapHtml ( htmlPayload ) ;
43+ expect ( new TextDecoder ( ) . decode ( result ) ) . to . equal ( 'Hello World' ) ;
44+ } ) ;
45+
46+ it ( 'should handle no quotes' , ( ) => {
47+ const htmlPayload = new TextEncoder ( ) . encode (
48+ '<input id=data-input type=hidden value=SGVsbG8gV29ybGQ=>'
49+ ) ;
50+ const result = unwrapHtml ( htmlPayload ) ;
51+ expect ( new TextDecoder ( ) . decode ( result ) ) . to . equal ( 'Hello World' ) ;
52+ } ) ;
53+
54+ it ( 'should handle URL-safe base64 characters' , ( ) => {
55+ const htmlPayload = new TextEncoder ( ) . encode (
56+ '<input id="data-input" type="hidden" value="SGVsbG8tV29ybGQ_">'
57+ ) ;
58+ const result = unwrapHtml ( htmlPayload ) ;
59+ expect ( new TextDecoder ( ) . decode ( result ) ) . to . equal ( 'Hello-World?' ) ;
60+ } ) ;
61+
62+ it ( 'should handle additional attributes' , ( ) => {
63+ const htmlPayload = new TextEncoder ( ) . encode (
64+ '<input class="hidden" id="data-input" data-test="value" type="hidden" value="SGVsbG8gV29ybGQ=">'
65+ ) ;
66+ const result = unwrapHtml ( htmlPayload ) ;
67+ expect ( new TextDecoder ( ) . decode ( result ) ) . to . equal ( 'Hello World' ) ;
68+ } ) ;
69+ } ) ;
2870} ) ;
0 commit comments