@@ -24,7 +24,7 @@ function applyTo(formData: FormData, keys: Record<string, string | boolean> | un
2424 const attributes : Record < string , unknown > = { } ;
2525 const span = { setAttribute : ( key : string , value : unknown ) => void ( attributes [ key ] = value ) } as unknown as Span ;
2626
27- applyFormDataAttributes ( span , formData , { keys } , 'formData.' ) ;
27+ applyFormDataAttributes ( span , formData , { keys } ) ;
2828
2929 return attributes ;
3030}
@@ -57,31 +57,34 @@ describe('applyFormDataAttributes', () => {
5757 it ( 'sets only allowlisted fields' , ( ) => {
5858 const attributes = applyTo ( formDataOf ( { username : 'alice' , bio : 'ignored' } ) , { username : true } ) ;
5959
60- expect ( attributes ) . toEqual ( { 'formData .username' : 'alice' } ) ;
60+ expect ( attributes ) . toEqual ( { 'remix.action_form_data .username' : 'alice' } ) ;
6161 } ) ;
6262
6363 it ( 'applies renames' , ( ) => {
6464 const attributes = applyTo ( formDataOf ( { username : 'alice' } ) , { username : 'user' } ) ;
6565
66- expect ( attributes ) . toEqual ( { 'formData .user' : 'alice' } ) ;
66+ expect ( attributes ) . toEqual ( { 'remix.action_form_data .user' : 'alice' } ) ;
6767 } ) ;
6868
6969 it ( 'sets every field when no keys are configured' , ( ) => {
7070 const attributes = applyTo ( formDataOf ( { username : 'alice' , bio : 'hello' } ) , undefined ) ;
7171
72- expect ( attributes ) . toEqual ( { 'formData. username' : 'alice' , 'formData .bio' : 'hello' } ) ;
72+ expect ( attributes ) . toEqual ( { 'remix.action_form_data. username' : 'alice' , 'remix.action_form_data .bio' : 'hello' } ) ;
7373 } ) ;
7474
7575 it ( 'filters sensitive values when capturing all fields' , ( ) => {
7676 const attributes = applyTo ( formDataOf ( { username : 'alice' , password : 'hunter2' } ) , undefined ) ;
7777
78- expect ( attributes ) . toEqual ( { 'formData.username' : 'alice' , 'formData.password' : '[Filtered]' } ) ;
78+ expect ( attributes ) . toEqual ( {
79+ 'remix.action_form_data.username' : 'alice' ,
80+ 'remix.action_form_data.password' : '[Filtered]' ,
81+ } ) ;
7982 } ) ;
8083
8184 it ( 'filters sensitive values even when explicitly allowlisted' , ( ) => {
8285 const attributes = applyTo ( formDataOf ( { password : 'hunter2' } ) , { password : true } ) ;
8386
84- expect ( attributes ) . toEqual ( { 'formData .password' : '[Filtered]' } ) ;
87+ expect ( attributes ) . toEqual ( { 'remix.action_form_data .password' : '[Filtered]' } ) ;
8588 } ) ;
8689
8790 it ( 'still filters a sensitive field renamed after rename' , ( ) => {
@@ -90,22 +93,22 @@ describe('applyFormDataAttributes', () => {
9093 // value ships in the clear.
9194 const attributes = applyTo ( formDataOf ( { password : 'hunter2' } ) , { password : 'pw' } ) ;
9295
93- expect ( attributes ) . toEqual ( { 'formData .pw' : '[Filtered]' } ) ;
96+ expect ( attributes ) . toEqual ( { 'remix.action_form_data .pw' : '[Filtered]' } ) ;
9497 } ) ;
9598
9699 it ( 'reports the filename for file uploads, not the contents' , ( ) => {
97100 const formData = new FormData ( ) ;
98101 formData . append ( 'avatar' , new Blob ( [ 'file contents' ] ) , 'avatar.png' ) ;
99102
100- expect ( applyTo ( formData , undefined ) ) . toEqual ( { 'formData .avatar' : 'avatar.png' } ) ;
103+ expect ( applyTo ( formData , undefined ) ) . toEqual ( { 'remix.action_form_data .avatar' : 'avatar.png' } ) ;
101104 } ) ;
102105
103106 it ( 'reports a placeholder for unnamed non-string values' , ( ) => {
104107 const formData = new FormData ( ) ;
105108 // An appended Blob with no filename reports as `blob` in undici; force the empty-name case.
106109 formData . append ( 'avatar' , new Blob ( [ 'x' ] ) , '' ) ;
107110
108- expect ( applyTo ( formData , undefined ) ) . toEqual ( { 'formData .avatar' : '[non-string value]' } ) ;
111+ expect ( applyTo ( formData , undefined ) ) . toEqual ( { 'remix.action_form_data .avatar' : '[non-string value]' } ) ;
109112 } ) ;
110113
111114 it ( 'sets nothing for an empty form' , ( ) => {
0 commit comments