Skip to content

Commit

Permalink
refactor: update contentDisposition function with ES6+ syntax for cla…
Browse files Browse the repository at this point in the history
…rity

- Replaced �ar with const for immutable values.
- Used default parameters and destructuring for options to simplify handling.
- Removed redundant variable initialization, enhancing readability.

This change modernizes the code, making it more concise and consistent with current JavaScript standards.
  • Loading branch information
Ayoub-Mabrouk committed Nov 11, 2024
1 parent 4b4684a commit d69268a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,11 @@ var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/
* @public
*/

function contentDisposition (filename, options) {
var opts = options || {}

// get type
var type = opts.type || 'attachment'
function contentDisposition (filename, options = {}) {
const { type = 'attachment', fallback } = options

// get parameters
var params = createparams(filename, opts.fallback)
const params = createparams(filename, fallback)

// format into string
return format(new ContentDisposition(type, params))
Expand Down

0 comments on commit d69268a

Please sign in to comment.