Skip to content

Commit 50cc670

Browse files
committed
1 parent d17de8c commit 50cc670

File tree

6 files changed

+31
-50
lines changed

6 files changed

+31
-50
lines changed

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
2.x
22
===
33

4+
* Change `dotfiles` option default to `'ignore'`
45
* Drop support for Node.js 0.8
6+
* Remove `hidden` option; use `dotfiles` option instead
7+
8+
- Use `mime-types` for file to content type mapping
9+
510

611
1.14.2 / 2021-12-15
712
===================

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ true. Disabling this will ignore the `immutable` and `maxAge` options.
4545

4646
##### dotfiles
4747

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

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

6261
##### etag
6362

@@ -215,7 +214,7 @@ app.listen(3000)
215214
#### Different settings for paths
216215

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

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

233232
app.listen(3000)
234233

235-
function setCustomCacheControl (res, path) {
236-
if (serveStatic.mime.lookup(path) === 'text/html') {
234+
function setCustomCacheControl (res, file) {
235+
if (path.extname(file) === '.html') {
237236
// Custom Cache-Control for HTML files
238237
res.setHeader('Cache-Control', 'public, max-age=0')
239238
}

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var url = require('url')
2626
*/
2727

2828
module.exports = serveStatic
29-
module.exports.mime = send.mime
3029

3130
/**
3231
* @param {string} root

package-lock.json

Lines changed: 19 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"encodeurl": "~1.0.2",
1010
"escape-html": "~1.0.3",
1111
"parseurl": "~1.3.3",
12-
"send": "0.17.2"
12+
"send": "1.0.0-beta.1"
1313
},
1414
"devDependencies": {
1515
"eslint": "7.32.0",

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('serveStatic()', function () {
4141
it('should set Content-Type', function (done) {
4242
request(server)
4343
.get('/todo.txt')
44-
.expect('Content-Type', 'text/plain; charset=UTF-8')
44+
.expect('Content-Type', 'text/plain; charset=utf-8')
4545
.expect(200, done)
4646
})
4747

0 commit comments

Comments
 (0)