Skip to content

Document that create does not strip the path from filename - #147

Merged
blakeembrey merged 1 commit into
jshttp:masterfrom
MFA-G:docs/create-basename
Nov 3, 2026
Merged

blakeembrey merged 1 commit into
jshttp:masterfrom
MFA-G:docs/create-basename

Conversation

@MFA-G

@MFA-G MFA-G commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Since 2.0.0, create no longer runs the filename through basename (the v2.0.0 release notes call this out), but the README doesn't mention it, and its "Send a file for download" example still passes the full path:

const filePath = '/path/to/public/plans.pdf';
res.setHeader('Content-Disposition', create(filePath));
// attachment; filename="/path/to/public/plans.pdf"

Copying that example sends the server's directory layout to the client. Under 1.x the same code produced filename="plans.pdf", so anyone who upgraded without reading the release notes gets a leak and nothing tells them.

Changes (README only):

  • Add a note under create(filename, options) that the filename is used as given and should be a bare file name (e.g. path.basename), not a full path.
  • Change the download example to create(path.basename(filePath)), which produces attachment; filename=plans.pdf.
  • Fix the leftover contentDisposition accepts these properties line to say create, since the default export was removed in 2.0.0.

I checked both outputs above against the built dist/. npm test passes and Prettier is clean.

@blakeembrey
blakeembrey merged commit dab4714 into jshttp:master Nov 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants