@@ -95,6 +95,40 @@ describe("parseAllowedFormats", () => {
95
95
"Value 'application-pdf' is not recognized. Accepted format: 'image/jpeg'"
96
96
) ;
97
97
} ) ;
98
+ test ( "handles extensions with special characters like dashes and plus signs" , ( ) => {
99
+ const input : AllowedFileFormatsType [ ] = [
100
+ {
101
+ configMode : "advanced" ,
102
+ typeFormatDescription : dynamicValue ( "special-extensions" ) ,
103
+ predefinedType : "pdfFile" ,
104
+ mimeType : "application/x-custom" ,
105
+ extensions : ".tar-gz,.js-map,.c++"
106
+ }
107
+ ] ;
108
+
109
+ expect ( parseAllowedFormats ( input ) ) . toEqual ( [
110
+ {
111
+ description : "special-extensions" ,
112
+ entries : [ [ "application/x-custom" , [ ".tar-gz" , ".js-map" , ".c++" ] ] ]
113
+ }
114
+ ] ) ;
115
+ } ) ;
116
+ test ( "throws on extension without leading dot" , ( ) => {
117
+ const input : AllowedFileFormatsType [ ] = [
118
+ {
119
+ configMode : "advanced" ,
120
+ typeFormatDescription : dynamicValue ( "test" ) ,
121
+ predefinedType : "pdfFile" ,
122
+ mimeType : "text/*" ,
123
+ extensions : ".txt,pdf"
124
+ }
125
+ ] ;
126
+
127
+ expect ( ( ) => parseAllowedFormats ( input ) ) . toThrow (
128
+ "Value 'pdf' is not recognized. Extension must start with a dot and contain only valid filename characters"
129
+ ) ;
130
+ } ) ;
131
+
98
132
test ( "throws on incorrect extension format" , ( ) => {
99
133
const input : AllowedFileFormatsType [ ] = [
100
134
{
@@ -106,6 +140,24 @@ describe("parseAllowedFormats", () => {
106
140
}
107
141
] ;
108
142
109
- expect ( ( ) => parseAllowedFormats ( input ) ) . toThrow ( "Value 'abc' is not recognized. Accepted format: '.pdf'" ) ;
143
+ expect ( ( ) => parseAllowedFormats ( input ) ) . toThrow (
144
+ "Value 'abc' is not recognized. Extension must start with a dot and contain only valid filename characters"
145
+ ) ;
146
+ } ) ;
147
+
148
+ test ( "throws on extension with dot in the middle" , ( ) => {
149
+ const input : AllowedFileFormatsType [ ] = [
150
+ {
151
+ configMode : "advanced" ,
152
+ typeFormatDescription : dynamicValue ( "test" ) ,
153
+ predefinedType : "pdfFile" ,
154
+ mimeType : "text/*" ,
155
+ extensions : ".txt,.config.json"
156
+ }
157
+ ] ;
158
+
159
+ expect ( ( ) => parseAllowedFormats ( input ) ) . toThrow (
160
+ "Value '.config.json' is not recognized. Extension must start with a dot and contain only valid filename characters"
161
+ ) ;
110
162
} ) ;
111
163
} ) ;
0 commit comments