diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index e3578aa..0000000 --- a/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "standard" -} diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000..cf3015f --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,9 @@ +root: true +extends: + - standard + - plugin:markdown/recommended +plugins: + - markdown +overrides: + - files: '**/*.md' + processor: 'markdown/markdown' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2eaea5a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,189 @@ +name: ci + +on: +- pull_request +- push + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + name: + - Node.js 0.8 + - Node.js 0.10 + - Node.js 0.12 + - io.js 1.x + - io.js 2.x + - io.js 3.x + - Node.js 4.x + - Node.js 5.x + - Node.js 6.x + - Node.js 7.x + - Node.js 8.x + - Node.js 9.x + - Node.js 10.x + - Node.js 11.x + - Node.js 12.x + - Node.js 13.x + - Node.js 14.x + - Node.js 15.x + - Node.js 16.x + - Node.js 17.x + + include: + - name: Node.js 0.8 + node-version: "0.8" + npm-i: mocha@2.5.3 supertest@1.1.0 + npm-rm: nyc + + - name: Node.js 0.10 + node-version: "0.10" + npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0 + + - name: Node.js 0.12 + node-version: "0.12" + npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0 + + - name: io.js 1.x + node-version: "1.8" + npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0 + + - name: io.js 2.x + node-version: "2.5" + npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0 + + - name: io.js 3.x + node-version: "3.3" + npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0 + + - name: Node.js 4.x + node-version: "4.9" + npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 + + - name: Node.js 5.x + node-version: "5.12" + npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 + + - name: Node.js 6.x + node-version: "6.17" + npm-i: mocha@6.2.3 nyc@14.1.1 supertest@6.1.6 + + - name: Node.js 7.x + node-version: "7.10" + npm-i: mocha@6.2.3 nyc@14.1.1 supertest@6.1.6 + + - name: Node.js 8.x + node-version: "8.16" + npm-i: mocha@7.2.0 + + - name: Node.js 9.x + node-version: "9.11" + npm-i: mocha@7.2.0 + + - name: Node.js 10.x + node-version: "10.24" + npm-i: mocha@8.4.0 + + - name: Node.js 11.x + node-version: "11.15" + npm-i: mocha@8.4.0 + + - name: Node.js 12.x + node-version: "12.22" + + - name: Node.js 13.x + node-version: "13.14" + + - name: Node.js 14.x + node-version: "14.19" + + - name: Node.js 15.x + node-version: "15.14" + + - name: Node.js 16.x + node-version: "16.14" + + - name: Node.js 17.x + node-version: "17.8" + + steps: + - uses: actions/checkout@v2 + + - name: Install Node.js ${{ matrix.node-version }} + shell: bash -eo pipefail -l {0} + run: | + nvm install --default ${{ matrix.node-version }} + if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + nvm install --alias=npm 0.10 + nvm use ${{ matrix.node-version }} + sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" + npm config set strict-ssl false + fi + dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" + + - name: Configure npm + run: npm config set shrinkwrap false + + - name: Remove npm module(s) ${{ matrix.npm-rm }} + run: npm rm --silent --save-dev ${{ matrix.npm-rm }} + if: matrix.npm-rm != '' + + - name: Install npm module(s) ${{ matrix.npm-i }} + run: npm install --save-dev ${{ matrix.npm-i }} + if: matrix.npm-i != '' + + - name: Setup Node.js version-specific dependencies + shell: bash + run: | + # eslint for linting + # - remove on Node.js < 10 + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ + grep -E '^eslint(-|$)' | \ + sort -r | \ + xargs -n1 npm rm --silent --save-dev + fi + + - name: Install Node.js dependencies + run: npm install + + - name: List environment + id: list_env + shell: bash + run: | + echo "node@$(node -v)" + echo "npm@$(npm -v)" + npm -s ls ||: + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' + + - name: Run tests + shell: bash + run: | + if npm -ps ls nyc | grep -q nyc; then + npm run test-ci + else + npm test + fi + + - name: Lint code + if: steps.list_env.outputs.eslint != '' + run: npm run lint + + - name: Collect code coverage + uses: coverallsapp/github-action@master + if: steps.list_env.outputs.nyc != '' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: run-${{ matrix.test_number }} + parallel: true + + coverage: + needs: test + runs-on: ubuntu-latest + steps: + - name: Uploade code coverage + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true diff --git a/.gitignore b/.gitignore index 3cd27af..f15b98e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.nyc_output/ coverage/ node_modules/ npm-debug.log +package-lock.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ae5f35e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,92 +0,0 @@ -language: node_js -node_js: - - "0.8" - - "0.10" - - "0.12" - - "1.8" - - "2.5" - - "3.3" - - "4.9" - - "5.12" - - "6.17" - - "7.10" - - "8.16" - - "9.11" - - "10.15" - - "11.15" - - "12.2" -sudo: false -cache: - directories: - - node_modules -before_install: - # Configure npm - - | - # Skip updating shrinkwrap / lock - npm config set shrinkwrap false - # Setup Node.js version-specific dependencies - - | - # mocha for testing - # - use 2.x for Node.js < 0.10 - # - use 3.x for Node.js < 4 - # - use 5.x for Node.js < 6 - if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then - npm install --save-dev mocha@2.5.3 - elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then - npm install --save-dev mocha@3.5.3 - elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then - npm install --save-dev mocha@5.2.0 - fi - - | - # supertest for http calls - # - use 1.1.0 for Node.js < 0.10 - # - use 2.0.0 for Node.js < 4 - # - use 3.4.2 for Node.js < 6 - if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then - npm install --save-dev supertest@1.1.0 - elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then - npm install --save-dev supertest@2.0.0 - elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then - npm install --save-dev supertest@3.4.2 - fi - - | - # istanbul for coverage - # - remove for Node.js < 0.10 - if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then - npm rm --silent --save-dev istanbul - fi - - | - # eslint for linting - # - remove on Node.js < 6 - if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then - node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ - grep -E '^eslint(-|$)' | \ - xargs npm rm --save-dev - fi - # Update Node.js modules - - | - # Prune and rebuild node_modules - if [[ -d node_modules ]]; then - npm prune - npm rebuild - fi -script: - # Run test script - - | - if npm -ps ls istanbul | grep -q istanbul; then - npm run test-ci - else - npm test - fi - # Run linting - - | - if npm -ps ls eslint | grep -q eslint; then - npm run lint - fi -after_script: - - | - # Upload coverage to coveralls - if [[ -f ./coverage/lcov.info ]]; then - npm install --save-dev coveralls@2.13.3 - coveralls < ./coverage/lcov.info - fi diff --git a/HISTORY.md b/HISTORY.md index 7203e4f..dccf667 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,39 @@ +1.16.2 / 2024-09-11 +=================== + +* deps: encodeurl@~2.0.0 + +1.16.1 / 2024-09-11 +=================== + +* deps: send@0.19.0 + +1.16.0 / 2024-09-10 +=================== + +* Remove link renderization in html while redirecting + + +1.15.0 / 2022-03-24 +=================== + + * deps: send@0.18.0 + - Fix emitted 416 error missing headers property + - Limit the headers removed for 304 response + - deps: depd@2.0.0 + - deps: destroy@1.2.0 + - deps: http-errors@2.0.0 + - deps: on-finished@2.4.1 + - deps: statuses@2.0.1 + +1.14.2 / 2021-12-15 +=================== + + * deps: send@0.17.2 + - deps: http-errors@1.8.1 + - deps: ms@2.1.3 + - pref: ignore empty http tokens + 1.14.1 / 2019-05-10 =================== diff --git a/README.md b/README.md index 7cce428..262d944 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] -[![Linux Build][travis-image]][travis-url] +[![Linux Build][github-actions-ci-image]][github-actions-ci-url] [![Windows Build][appveyor-image]][appveyor-url] [![Test Coverage][coveralls-image]][coveralls-url] @@ -18,8 +18,6 @@ $ npm install serve-static ## API - - ```js var serveStatic = require('serve-static') ``` @@ -141,7 +139,7 @@ var http = require('http') var serveStatic = require('serve-static') // Serve up public/ftp folder -var serve = serveStatic('public/ftp', { 'index': ['index.html', 'index.htm'] }) +var serve = serveStatic('public/ftp', { index: ['index.html', 'index.htm'] }) // Create server var server = http.createServer(function onRequest (req, res) { @@ -162,8 +160,8 @@ var serveStatic = require('serve-static') // Serve up public/ftp folder var serve = serveStatic('public/ftp', { - 'index': false, - 'setHeaders': setHeaders + index: false, + setHeaders: setHeaders }) // Set header to force download @@ -192,15 +190,15 @@ var serveStatic = require('serve-static') var app = express() -app.use(serveStatic('public/ftp', { 'index': ['default.html', 'default.htm'] })) +app.use(serveStatic('public/ftp', { index: ['default.html', 'default.htm'] })) app.listen(3000) ``` #### Multiple roots This example shows a simple way to search through multiple directories. -Files are look for in `public-optimized/` first, then `public/` second as -a fallback. +Files are searched for in `public-optimized/` first, then `public/` second +as a fallback. ```js var express = require('express') @@ -250,10 +248,10 @@ function setCustomCacheControl (res, path) { [appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-static [coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/serve-static/master [coveralls-url]: https://coveralls.io/r/expressjs/serve-static?branch=master +[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/serve-static/master?label=linux +[github-actions-ci-url]: https://github.com/expressjs/serve-static/actions/workflows/ci.yml [node-image]: https://badgen.net/npm/node/serve-static [node-url]: https://nodejs.org/en/download/ [npm-downloads-image]: https://badgen.net/npm/dm/serve-static [npm-url]: https://npmjs.org/package/serve-static [npm-version-image]: https://badgen.net/npm/v/serve-static -[travis-image]: https://badgen.net/travis/expressjs/serve-static/master?label=linux -[travis-url]: https://travis-ci.org/expressjs/serve-static diff --git a/appveyor.yml b/appveyor.yml index 40abaa1..d1d6862 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,5 @@ environment: matrix: - - nodejs_version: "0.8" - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "1.8" @@ -12,9 +11,14 @@ environment: - nodejs_version: "7.10" - nodejs_version: "8.16" - nodejs_version: "9.11" - - nodejs_version: "10.15" + - nodejs_version: "10.24" - nodejs_version: "11.15" - - nodejs_version: "12.2" + - nodejs_version: "12.22" + - nodejs_version: "13.14" + - nodejs_version: "14.19" + - nodejs_version: "15.14" + - nodejs_version: "16.14" + - nodejs_version: "17.8" cache: - node_modules install: @@ -26,14 +30,10 @@ install: - ps: | # Skip updating shrinkwrap / lock npm config set shrinkwrap false - # Skip SSL validation on Node.js < 0.10 - if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) { - npm config set strict-ssl false - } # Remove all non-test dependencies - ps: | # Remove coverage dependency - npm rm --silent --save-dev istanbul + npm rm --silent --save-dev nyc # Remove lint dependencies cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | ` sls "^eslint(-|$)" | ` @@ -44,24 +44,36 @@ install: # - use 2.x for Node.js < 0.10 # - use 3.x for Node.js < 4 # - use 5.x for Node.js < 6 + # - use 6.x for Node.js < 8 + # - use 7.x for Node.js < 10 + # - use 8.x for Node.js < 12 if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) { npm install --silent --save-dev mocha@2.5.3 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 4) { npm install --silent --save-dev mocha@3.5.3 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) { npm install --silent --save-dev mocha@5.2.0 + } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) { + npm install --silent --save-dev mocha@6.2.3 + } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) { + npm install --silent --save-dev mocha@7.2.0 + } elseif ([int]$env:nodejs_version.split(".")[0] -lt 12) { + npm install --silent --save-dev mocha@8.4.0 } - ps: | # supertest for http calls # - use 1.1.0 for Node.js < 0.10 # - use 2.0.0 for Node.js < 4 # - use 3.4.2 for Node.js < 6 + # - use 6.1.6 for Node.js < 8 if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) { npm install --silent --save-dev supertest@1.1.0 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 4) { npm install --silent --save-dev supertest@2.0.0 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) { npm install --silent --save-dev supertest@3.4.2 + } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) { + npm install --silent --save-dev supertest@6.1.6 } # Update Node.js modules - ps: | diff --git a/index.js b/index.js index b7d3984..3f3e64e 100644 --- a/index.js +++ b/index.js @@ -195,8 +195,7 @@ function createRedirectDirectoryListener () { // reformat the URL var loc = encodeUrl(url.format(originalUrl)) - var doc = createHtmlDocument('Redirecting', 'Redirecting to ' + - escapeHtml(loc) + '') + var doc = createHtmlDocument('Redirecting', 'Redirecting to ' + escapeHtml(loc)) // send redirect response res.statusCode = 301 diff --git a/package.json b/package.json index a60c83f..49d7542 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,28 @@ { "name": "serve-static", "description": "Serve static files", - "version": "1.14.1", + "version": "1.16.2", "author": "Douglas Christopher Wilson ", "license": "MIT", "repository": "expressjs/serve-static", "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.19.0" }, "devDependencies": { - "eslint": "5.16.0", - "eslint-config-standard": "12.0.0", - "eslint-plugin-import": "2.17.2", - "eslint-plugin-markdown": "1.0.0", - "eslint-plugin-node": "8.0.1", - "eslint-plugin-promise": "4.1.1", - "eslint-plugin-standard": "4.0.0", - "istanbul": "0.4.5", - "mocha": "6.1.4", - "safe-buffer": "5.1.2", - "supertest": "4.0.2" + "eslint": "7.32.0", + "eslint-config-standard": "14.1.1", + "eslint-plugin-import": "2.25.4", + "eslint-plugin-markdown": "2.2.1", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-promise": "5.2.0", + "eslint-plugin-standard": "4.1.0", + "mocha": "9.2.2", + "nyc": "15.1.0", + "safe-buffer": "5.2.1", + "supertest": "6.2.2" }, "files": [ "LICENSE", @@ -33,10 +33,10 @@ "node": ">= 0.8.0" }, "scripts": { - "lint": "eslint --plugin markdown --ext js,md .", + "lint": "eslint .", "test": "mocha --reporter spec --bail --check-leaks test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-ci": "nyc --reporter=lcov --reporter=text npm test", + "test-cov": "nyc --reporter=html --reporter=text npm test", "version": "node scripts/version-history.js && git add HISTORY.md" } } diff --git a/test/test.js b/test/test.js index 94a6c6a..7bce038 100644 --- a/test/test.js +++ b/test/test.js @@ -150,14 +150,14 @@ describe('serveStatic()', function () { describe('acceptRanges', function () { describe('when false', function () { it('should not include Accept-Ranges', function (done) { - request(createServer(fixtures, { 'acceptRanges': false })) + request(createServer(fixtures, { acceptRanges: false })) .get('/nums.txt') .expect(shouldNotHaveHeader('Accept-Ranges')) .expect(200, '123456789', done) }) it('should ignore Rage request header', function (done) { - request(createServer(fixtures, { 'acceptRanges': false })) + request(createServer(fixtures, { acceptRanges: false })) .get('/nums.txt') .set('Range', 'bytes=0-3') .expect(shouldNotHaveHeader('Accept-Ranges')) @@ -168,14 +168,14 @@ describe('serveStatic()', function () { describe('when true', function () { it('should include Accept-Ranges', function (done) { - request(createServer(fixtures, { 'acceptRanges': true })) + request(createServer(fixtures, { acceptRanges: true })) .get('/nums.txt') .expect('Accept-Ranges', 'bytes') .expect(200, '123456789', done) }) it('should obey Rage request header', function (done) { - request(createServer(fixtures, { 'acceptRanges': true })) + request(createServer(fixtures, { acceptRanges: true })) .get('/nums.txt') .set('Range', 'bytes=0-3') .expect('Accept-Ranges', 'bytes') @@ -188,14 +188,14 @@ describe('serveStatic()', function () { describe('cacheControl', function () { describe('when false', function () { it('should not include Cache-Control', function (done) { - request(createServer(fixtures, { 'cacheControl': false })) + request(createServer(fixtures, { cacheControl: false })) .get('/nums.txt') .expect(shouldNotHaveHeader('Cache-Control')) .expect(200, '123456789', done) }) it('should ignore maxAge', function (done) { - request(createServer(fixtures, { 'cacheControl': false, 'maxAge': 12000 })) + request(createServer(fixtures, { cacheControl: false, maxAge: 12000 })) .get('/nums.txt') .expect(shouldNotHaveHeader('Cache-Control')) .expect(200, '123456789', done) @@ -204,7 +204,7 @@ describe('serveStatic()', function () { describe('when true', function () { it('should include Cache-Control', function (done) { - request(createServer(fixtures, { 'cacheControl': true })) + request(createServer(fixtures, { cacheControl: true })) .get('/nums.txt') .expect('Cache-Control', 'public, max-age=0') .expect(200, '123456789', done) @@ -222,7 +222,7 @@ describe('serveStatic()', function () { }) it('should be configurable', function (done) { - var server = createServer(fixtures, { 'extensions': 'txt' }) + var server = createServer(fixtures, { extensions: 'txt' }) request(server) .get('/todo') @@ -230,7 +230,7 @@ describe('serveStatic()', function () { }) it('should support disabling extensions', function (done) { - var server = createServer(fixtures, { 'extensions': false }) + var server = createServer(fixtures, { extensions: false }) request(server) .get('/todo') @@ -238,7 +238,7 @@ describe('serveStatic()', function () { }) it('should support fallbacks', function (done) { - var server = createServer(fixtures, { 'extensions': ['htm', 'html', 'txt'] }) + var server = createServer(fixtures, { extensions: ['htm', 'html', 'txt'] }) request(server) .get('/todo') @@ -246,7 +246,7 @@ describe('serveStatic()', function () { }) it('should 404 if nothing found', function (done) { - var server = createServer(fixtures, { 'extensions': ['htm', 'html', 'txt'] }) + var server = createServer(fixtures, { extensions: ['htm', 'html', 'txt'] }) request(server) .get('/bob') @@ -263,7 +263,7 @@ describe('serveStatic()', function () { describe('when true', function () { before(function () { - this.server = createServer(fixtures, { 'fallthrough': true }) + this.server = createServer(fixtures, { fallthrough: true }) }) it('should fall-through when OPTIONS request', function (done) { @@ -287,14 +287,14 @@ describe('serveStatic()', function () { it('should fall-through when URL too long', function (done) { var root = fixtures + Array(10000).join('/foobar') - request(createServer(root, { 'fallthrough': true })) + request(createServer(root, { fallthrough: true })) .get('/') .expect(404, 'sorry!', done) }) describe('with redirect: true', function () { before(function () { - this.server = createServer(fixtures, { 'fallthrough': true, 'redirect': true }) + this.server = createServer(fixtures, { fallthrough: true, redirect: true }) }) it('should fall-through when directory', function (done) { @@ -312,7 +312,7 @@ describe('serveStatic()', function () { describe('with redirect: false', function () { before(function () { - this.server = createServer(fixtures, { 'fallthrough': true, 'redirect': false }) + this.server = createServer(fixtures, { fallthrough: true, redirect: false }) }) it('should fall-through when directory', function (done) { @@ -331,7 +331,7 @@ describe('serveStatic()', function () { describe('when false', function () { before(function () { - this.server = createServer(fixtures, { 'fallthrough': false }) + this.server = createServer(fixtures, { fallthrough: false }) }) it('should 405 when OPTIONS request', function (done) { @@ -356,14 +356,14 @@ describe('serveStatic()', function () { it('should 404 when URL too long', function (done) { var root = fixtures + Array(10000).join('/foobar') - request(createServer(root, { 'fallthrough': false })) + request(createServer(root, { fallthrough: false })) .get('/') .expect(404, /ENAMETOOLONG/, done) }) describe('with redirect: true', function () { before(function () { - this.server = createServer(fixtures, { 'fallthrough': false, 'redirect': true }) + this.server = createServer(fixtures, { fallthrough: false, redirect: true }) }) it('should 404 when directory', function (done) { @@ -381,7 +381,7 @@ describe('serveStatic()', function () { describe('with redirect: false', function () { before(function () { - this.server = createServer(fixtures, { 'fallthrough': false, 'redirect': false }) + this.server = createServer(fixtures, { fallthrough: false, redirect: false }) }) it('should 404 when directory', function (done) { @@ -402,7 +402,7 @@ describe('serveStatic()', function () { describe('hidden files', function () { var server before(function () { - server = createServer(fixtures, { 'dotfiles': 'allow' }) + server = createServer(fixtures, { dotfiles: 'allow' }) }) it('should be served when dotfiles: "allow" is given', function (done) { @@ -422,7 +422,7 @@ describe('serveStatic()', function () { }) it('should set immutable directive in Cache-Control', function (done) { - request(createServer(fixtures, { 'immutable': true, 'maxAge': '1h' })) + request(createServer(fixtures, { immutable: true, maxAge: '1h' })) .get('/nums.txt') .expect('Cache-Control', 'public, max-age=3600, immutable', done) }) @@ -431,7 +431,7 @@ describe('serveStatic()', function () { describe('lastModified', function () { describe('when false', function () { it('should not include Last-Modifed', function (done) { - request(createServer(fixtures, { 'lastModified': false })) + request(createServer(fixtures, { lastModified: false })) .get('/nums.txt') .expect(shouldNotHaveHeader('Last-Modified')) .expect(200, '123456789', done) @@ -440,7 +440,7 @@ describe('serveStatic()', function () { describe('when true', function () { it('should include Last-Modifed', function (done) { - request(createServer(fixtures, { 'lastModified': true })) + request(createServer(fixtures, { lastModified: true })) .get('/nums.txt') .expect('Last-Modified', /^\w{3}, \d+ \w+ \d+ \d+:\d+:\d+ \w+$/) .expect(200, '123456789', done) @@ -450,14 +450,14 @@ describe('serveStatic()', function () { describe('maxAge', function () { it('should accept string', function (done) { - request(createServer(fixtures, { 'maxAge': '30d' })) + request(createServer(fixtures, { maxAge: '30d' })) .get('/todo.txt') .expect('cache-control', 'public, max-age=' + (60 * 60 * 24 * 30)) .expect(200, done) }) it('should be reasonable when infinite', function (done) { - request(createServer(fixtures, { 'maxAge': Infinity })) + request(createServer(fixtures, { maxAge: Infinity })) .get('/todo.txt') .expect('cache-control', 'public, max-age=' + (60 * 60 * 24 * 365)) .expect(200, done) @@ -483,7 +483,7 @@ describe('serveStatic()', function () { request(server) .get('/users') .expect('Location', '/users/') - .expect(301, //, done) + .expect(301, /\/users\//, done) }) it('should redirect directories with query string', function (done) { @@ -505,7 +505,7 @@ describe('serveStatic()', function () { .get('/snow') .expect('Location', '/snow%20%E2%98%83/') .expect('Content-Type', /html/) - .expect(301, />Redirecting to \/snow%20%E2%98%83\/<\/a>Redirecting to \/snow%20%E2%98%83\/ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy