Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
  • Loading branch information
dougwilson authored and wesleytodd committed Jul 26, 2024
commit 3f5a845c1ba9d3fc5466551274d79a68a6e1dce6
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
2.x
===

* Change `dotfiles` option default to `'ignore'`
* Drop support for Node.js 0.8
* Remove `hidden` option; use `dotfiles` option instead
* deps: [email protected]
- Use `mime-types` for file to content type mapping
- deps: [email protected]

1.15.0 / 2022-03-24
===================
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ true. Disabling this will ignore the `immutable` and `maxAge` options.

##### dotfiles

Set how "dotfiles" are treated when encountered. A dotfile is a file
Set how "dotfiles" are treated when encountered. A dotfile is a file
or directory that begins with a dot ("."). Note this check is done on
the path itself without checking if the path actually exists on the
disk. If `root` is specified, only the dotfiles above the root are
Expand All @@ -56,8 +56,7 @@ to "deny").
- `'deny'` Deny a request for a dotfile and 403/`next()`.
- `'ignore'` Pretend like the dotfile does not exist and 404/`next()`.

The default value is similar to `'ignore'`, with the exception that this
default will not ignore the files within a directory that begins with a dot.
The default value is `'ignore'`.

##### etag

Expand Down Expand Up @@ -215,7 +214,7 @@ app.listen(3000)
#### Different settings for paths

This example shows how to set a different max age depending on the served
file type. In this example, HTML files are not cached, while everything else
file. In this example, HTML files are not cached, while everything else
is for 1 day.

```js
Expand All @@ -232,8 +231,8 @@ app.use(serveStatic(path.join(__dirname, 'public'), {

app.listen(3000)

function setCustomCacheControl (res, path) {
if (serveStatic.mime.lookup(path) === 'text/html') {
function setCustomCacheControl (res, file) {
if (path.extname(file) === '.html') {
// Custom Cache-Control for HTML files
res.setHeader('Cache-Control', 'public, max-age=0')
}
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var url = require('url')
*/

module.exports = serveStatic
module.exports.mime = send.mime

/**
* @param {string} root
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
<<<<<<< HEAD
"send": "0.18.0"
=======
"send": "1.0.0-beta.1"
>>>>>>> 50cc670 (deps: [email protected])
},
"devDependencies": {
"eslint": "7.32.0",
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('serveStatic()', function () {
it('should set Content-Type', function (done) {
request(server)
.get('/todo.txt')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(200, done)
})

Expand Down