serve-handler
Advanced tools
Comparing version 2.3.5 to 2.3.6
{ | ||
"name": "serve-handler", | ||
"version": "2.3.5", | ||
"version": "2.3.6", | ||
"description": "The routing foundation of `serve` and static deployments on Now", | ||
@@ -9,3 +9,4 @@ "main": "src/index.js", | ||
"test-lint": "zeit-eslint --ext .jsx,.js .", | ||
"test-integration": "ava test/integration.js --fail-fast", | ||
"test-integration": "nyc --reporter=html --reporter=text ava test/integration.js", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint", | ||
@@ -31,2 +32,3 @@ "build-views": "dottojs -s ./src -d ./src", | ||
"ava": "0.25.0", | ||
"codecov": "3.0.2", | ||
"commander": "2.15.1", | ||
@@ -37,2 +39,3 @@ "dot": "1.1.2", | ||
"node-fetch": "2.1.2", | ||
"nyc": "11.8.0", | ||
"request": "2.87.0", | ||
@@ -46,4 +49,11 @@ "test-listen": "1.1.0" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"src/directory.js", | ||
"test/*" | ||
] | ||
}, | ||
"eslintIgnore": [ | ||
"directory.js" | ||
"directory.js", | ||
"coverage" | ||
], | ||
@@ -50,0 +60,0 @@ "git": { |
# serve-handler | ||
[![Build Status](https://circleci.com/gh/zeit/serve-handler.svg?&style=shield&circle-token=75e1ee77692419df0d17174ce5c7b5fe2d2a78a6)](https://circleci.com/gh/zeit/serve-handler) | ||
[![Build Status](https://circleci.com/gh/zeit/serve-handler.svg?&style=shield)](https://circleci.com/gh/zeit/serve-handler) | ||
[![codecov](https://codecov.io/gh/zeit/serve-handler/branch/master/graph/badge.svg)](https://codecov.io/gh/zeit/serve-handler) | ||
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/micro/serve) | ||
@@ -24,3 +25,3 @@ | ||
Next, add it to your HTTP server. Here's an example with [micro](https://github.com/zeit/micro): | ||
Next, add it to your HTTP server. Here's an example using [micro](https://github.com/zeit/micro): | ||
@@ -49,10 +50,12 @@ ```js | ||
- [public](#public-boolean) (set sub directory to serve) | ||
- [cleanUrls](#cleanurls-booleanarray) (strip `.html` and `.htm` from paths) | ||
- [rewrites](#rewrites-array) (rewrite paths to different paths) | ||
- [redirects](#redirects-array) (forward paths to different paths or URLs) | ||
- [headers](#headers-array) (set custom headers) | ||
- [directoryListing](#directorylisting-booleanarray) (disable directory listing or restrict it to certain paths) | ||
- [unlisted](#unlisted-array) (exclude paths from the directory listing) | ||
- [trailingSlash](#trailingslash-boolean) (remove or add trailing slashes to all paths) | ||
| Property | Description | | ||
|------------------------------------------------------|-----------------------------------------------------------| | ||
| [`public`](#public-boolean) | Set a sub directory to be served | | ||
| [`cleanUrls`](#cleanurls-booleanarray) | Have `.html` and `.htm` extension stripped from paths | | ||
| [`rewrites`](#rewrites-array) | Rewrite paths to different paths | | ||
| [`redirects`](#redirects-array) | Forward paths to different paths or external URLs | | ||
| [`headers`](#headers-array) | Set custom headers for specific paths | | ||
| [`directoryListing`](#directorylisting-booleanarray) | Disable directory listing or restrict it to certain paths | | ||
| [`unlisted`](#unlisted-array) | Exclude paths from the directory listing | | ||
| [`trailingSlash`](#trailingslash-boolean) | Remove or add trailing slashes to all paths | | ||
@@ -221,4 +224,2 @@ ### public (Boolean) | ||
This comes in handy if you're dealing with simulating a file system, for example. | ||
These are the methods used by the package (they can all return a `Promise` or be asynchronous): | ||
@@ -234,3 +235,3 @@ | ||
## Real-World Use Cases | ||
## Use Cases | ||
@@ -237,0 +238,0 @@ There are two environments in which [ZEIT](https://zeit.co) uses this package: |
@@ -91,3 +91,3 @@ // Native | ||
if (redirects.length === 0 && !slashing) { | ||
if (redirects.length === 0 && !slashing && !cleanUrl) { | ||
return null; | ||
@@ -278,3 +278,3 @@ } | ||
if (!applicable(relativePath, directoryListing, false)) { | ||
if (directoryListing === false || !applicable(relativePath, directoryListing, false)) { | ||
return null; | ||
@@ -329,2 +329,3 @@ } | ||
/* istanbul ignore next */ | ||
if (aIsDir && !bIsDir) { | ||
@@ -342,2 +343,3 @@ return -1; | ||
/* istanbul ignore next */ | ||
return 0; | ||
@@ -499,3 +501,3 @@ }).filter(Boolean); | ||
try { | ||
stats = await handlers.stat(errorPage); | ||
stats = await handlers.stat(errorPageFull); | ||
} catch (err) { | ||
@@ -521,4 +523,4 @@ if (err.code !== 'ENOENT') { | ||
response.writeHead(200, headers); | ||
response.writeHead(response.statusCode || 200, headers); | ||
handlers.createReadStream(absolutePath).pipe(response); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29847
435
249
12