File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -231,10 +231,13 @@ impl HeaderContext {
231231 async fn csv ( mut self , options : & JsonValue ) -> anyhow:: Result < PageContext > {
232232 self . response
233233 . insert_header ( ( header:: CONTENT_TYPE , "text/csv; charset=utf-8" ) ) ;
234- if let Some ( filename) = get_object_str ( options, "filename" ) {
234+ if let Some ( filename) =
235+ get_object_str ( options, "filename" ) . or_else ( || get_object_str ( options, "title" ) )
236+ {
237+ let extension = if filename. contains ( '.' ) { "" } else { ".csv" } ;
235238 self . response . insert_header ( (
236239 header:: CONTENT_DISPOSITION ,
237- format ! ( "attachment; filename={filename}" ) ,
240+ format ! ( "attachment; filename={filename}{extension} " ) ,
238241 ) ) ;
239242 }
240243 let csv_renderer = CsvBodyRenderer :: new ( self . writer , options) . await ?;
You can’t perform that action at this time.
0 commit comments