@@ -19,11 +19,51 @@ describe('contentDisposition(filename)', function () {
1919 'attachment; filename="plans.pdf"' )
2020 } )
2121
22- it ( 'should use the basename of the string ' , function ( ) {
22+ it ( 'should use the basename of a posix path ' , function ( ) {
2323 assert . strictEqual ( contentDisposition ( '/path/to/plans.pdf' ) ,
2424 'attachment; filename="plans.pdf"' )
2525 } )
2626
27+ it ( 'should use the basename of a windows path' , function ( ) {
28+ assert . strictEqual ( contentDisposition ( '\\path\\to\\plans.pdf' ) ,
29+ 'attachment; filename="plans.pdf"' )
30+ } )
31+
32+ it ( 'should use the basename of a windows path with drive letter' , function ( ) {
33+ assert . strictEqual ( contentDisposition ( 'C:\\path\\to\\plans.pdf' ) ,
34+ 'attachment; filename="plans.pdf"' )
35+ } )
36+
37+ it ( 'should use the basename of a posix path with trailing slash' , function ( ) {
38+ assert . strictEqual ( contentDisposition ( '/path/to/plans.pdf/' ) ,
39+ 'attachment; filename="plans.pdf"' )
40+ } )
41+
42+ it ( 'should use the basename of a windows path with trailing slash' , function ( ) {
43+ assert . strictEqual ( contentDisposition ( '\\path\\to\\plans.pdf\\' ) ,
44+ 'attachment; filename="plans.pdf"' )
45+ } )
46+
47+ it ( 'should use the basename of a windows path with drive letter and trailing slash' , function ( ) {
48+ assert . strictEqual ( contentDisposition ( 'C:\\path\\to\\plans.pdf\\' ) ,
49+ 'attachment; filename="plans.pdf"' )
50+ } )
51+
52+ it ( 'should use the basename of a posix path with trailing slashes' , function ( ) {
53+ assert . strictEqual ( contentDisposition ( '/path/to/plans.pdf///' ) ,
54+ 'attachment; filename="plans.pdf"' )
55+ } )
56+
57+ it ( 'should use the basename of a windows path with trailing slashes' , function ( ) {
58+ assert . strictEqual ( contentDisposition ( '\\path\\to\\plans.pdf\\\\\\' ) ,
59+ 'attachment; filename="plans.pdf"' )
60+ } )
61+
62+ it ( 'should use the basename of a windows path with drive letter and trailing slashes' , function ( ) {
63+ assert . strictEqual ( contentDisposition ( 'C:\\path\\to\\plans.pdf\\\\\\' ) ,
64+ 'attachment; filename="plans.pdf"' )
65+ } )
66+
2767 describe ( 'when "filename" is US-ASCII' , function ( ) {
2868 it ( 'should only include filename parameter' , function ( ) {
2969 assert . strictEqual ( contentDisposition ( 'plans.pdf' ) ,
@@ -137,11 +177,21 @@ describe('contentDisposition(filename, options)', function () {
137177 'attachment; filename="plans.pdf"' )
138178 } )
139179
140- it ( 'should use the basename of the string ' , function ( ) {
180+ it ( 'should use the basename of a posix path ' , function ( ) {
141181 assert . strictEqual ( contentDisposition ( '€ rates.pdf' , { fallback : '/path/to/EURO rates.pdf' } ) ,
142182 'attachment; filename="EURO rates.pdf"; filename*=UTF-8\'\'%E2%82%AC%20rates.pdf' )
143183 } )
144184
185+ it ( 'should use the basename of a windows path' , function ( ) {
186+ assert . strictEqual ( contentDisposition ( '€ rates.pdf' , { fallback : '\\path\\to\\EURO rates.pdf' } ) ,
187+ 'attachment; filename="EURO rates.pdf"; filename*=UTF-8\'\'%E2%82%AC%20rates.pdf' )
188+ } )
189+
190+ it ( 'should use the basename of a windows path with drive letter' , function ( ) {
191+ assert . strictEqual ( contentDisposition ( '€ rates.pdf' , { fallback : 'C:\\path\\to\\EURO rates.pdf' } ) ,
192+ 'attachment; filename="EURO rates.pdf"; filename*=UTF-8\'\'%E2%82%AC%20rates.pdf' )
193+ } )
194+
145195 it ( 'should do nothing without filename option' , function ( ) {
146196 assert . strictEqual ( contentDisposition ( undefined , { fallback : 'plans.pdf' } ) ,
147197 'attachment' )
0 commit comments