Socket
Socket
Sign inDemoInstall

serve-handler

Package Overview
Dependencies
19
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.3 to 2.3.4

14

package.json
{
"name": "serve-handler",
"version": "2.3.3",
"version": "2.3.4",
"description": "The routing foundation of `serve` and static deployments on Now",
"main": "src/index.js",
"scripts": {
"test": "yarn run lint",
"lint": "zeit-eslint --ext .jsx,.js .",
"test": "yarn run test-lint && yarn run test-integration",
"test-lint": "zeit-eslint --ext .jsx,.js .",
"test-integration": "ava test/integration.js --fail-fast",
"lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint",

@@ -27,5 +28,10 @@ "build-views": "dottojs -s ./src -d ./src",

"@zeit/git-hooks": "0.1.4",
"ava": "0.25.0",
"commander": "2.15.1",
"dot": "1.1.2",
"eslint": "4.19.1"
"eslint": "4.19.1",
"micro": "9.3.1",
"node-fetch": "2.1.2",
"request": "2.87.0",
"test-listen": "1.1.0"
},

@@ -32,0 +38,0 @@ "eslintConfig": {

@@ -224,3 +224,3 @@ # serve-handler

```js
await handler(request, response, null, {
await handler(request, response, undefined, {
stat(path) {},

@@ -227,0 +227,0 @@ createReadStream(path) {},

@@ -89,3 +89,5 @@ // Native

const shouldRedirect = (decodedPath, {redirects = [], trailingSlash}, cleanUrl) => {
if (redirects.length === 0) {
const slashing = typeof trailingSlash === 'boolean';
if (redirects.length === 0 && !slashing) {
return null;

@@ -108,3 +110,3 @@ }

if (typeof trailingSlash === 'boolean') {
if (slashing) {
const {ext, name} = path.parse(decodedPath);

@@ -435,4 +437,8 @@ const isTrailed = decodedPath.endsWith('/');

const acceptsJSON = request.headers.accept.includes('application/json');
let acceptsJSON = null;
if (request.headers.accept) {
acceptsJSON = request.headers.accept.includes('application/json');
}
if (((stats && stats.isDirectory()) || !stats) && acceptsJSON) {

@@ -459,4 +465,9 @@ response.setHeader('Content-Type', 'application/json');

response.statusCode = 200;
// When JSON is accepted, we already set the header before
if (!response.getHeader('Content-Type')) {
response.setHeader('Content-Type', 'text/html; charset=utf-8');
}
response.end(directory);
return;

@@ -463,0 +474,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc