Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 5, 2022
1 parent d17de8c commit 50cc670
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 50 deletions.
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.14.2 / 2021-12-15
===================
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
60 changes: 19 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.17.2"
"send": "1.0.0-beta.1"
},
"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

0 comments on commit 50cc670

Please sign in to comment.