@@ -42,5 +42,74 @@ describe('res', function(){
4242 . get ( '/' )
4343 . expect ( 'Content-Type' , 'application/vnd.amazon.ebook' , done ) ;
4444 } )
45+
46+ describe ( 'edge cases' , function ( ) {
47+ it ( 'should handle empty string gracefully' , function ( done ) {
48+ var app = express ( ) ;
49+
50+ app . use ( function ( req , res ) {
51+ res . type ( '' ) . end ( 'test' ) ;
52+ } ) ;
53+
54+ request ( app )
55+ . get ( '/' )
56+ . expect ( 'Content-Type' , 'application/octet-stream' )
57+ . end ( done ) ;
58+ } )
59+
60+ it ( 'should handle file extension with dots' , function ( done ) {
61+ var app = express ( ) ;
62+
63+ app . use ( function ( req , res ) {
64+ res . type ( '.json' ) . end ( '{"test": true}' ) ;
65+ } ) ;
66+
67+ request ( app )
68+ . get ( '/' )
69+ . expect ( 'Content-Type' , 'application/json; charset=utf-8' )
70+ . end ( done ) ;
71+ } )
72+
73+ it ( 'should handle multiple file extensions' , function ( done ) {
74+ var app = express ( ) ;
75+
76+ app . use ( function ( req , res ) {
77+ res . type ( 'file.tar.gz' ) . end ( 'compressed' ) ;
78+ } ) ;
79+
80+ request ( app )
81+ . get ( '/' )
82+ . expect ( 'Content-Type' , 'application/gzip' )
83+ . end ( done ) ;
84+ } )
85+
86+ it ( 'should handle uppercase extensions' , function ( done ) {
87+ var app = express ( ) ;
88+
89+ app . use ( function ( req , res ) {
90+ res . type ( 'FILE.JSON' ) . end ( '{"test": true}' ) ;
91+ } ) ;
92+
93+ request ( app )
94+ . get ( '/' )
95+ . expect ( 'Content-Type' , 'application/json; charset=utf-8' )
96+ . end ( done ) ;
97+ } )
98+
99+ it ( 'should handle extension with special characters' , function ( done ) {
100+ var app = express ( ) ;
101+
102+ app . use ( function ( req , res ) {
103+ res . type ( 'file@test.json' ) . end ( '{"test": true}' ) ;
104+ } ) ;
105+
106+ request ( app )
107+ . get ( '/' )
108+ . expect ( 'Content-Type' , 'application/json; charset=utf-8' )
109+ . end ( done ) ;
110+ } )
111+ } )
45112 } )
46113} )
114+
115+
0 commit comments