🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

serve-handler

Package Overview
Dependencies
Maintainers
7
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serve-handler - npm Package Compare versions

Comparing version

to
6.1.5

13

package.json
{
"name": "serve-handler",
"version": "6.1.2",
"version": "6.1.5",
"description": "The routing foundation of `serve` and static deployments on Now",

@@ -10,6 +10,6 @@ "main": "src/index.js",

"test-integration": "nyc --reporter=html --reporter=text ava test/integration.js",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint",
"build-views": "dottojs -s ./src -d ./src",
"prepublish": "yarn run build-views"
"prepublishOnly": "yarn run build-views"
},

@@ -34,9 +34,8 @@ "repository": "zeit/serve-handler",

"ava": "2.2.0",
"codecov": "3.0.2",
"commander": "2.15.1",
"dot": "1.1.2",
"dot": "1.1.3",
"eslint": "6.1.0",
"fs-extra": "6.0.1",
"micro": "9.3.2",
"node-fetch": "2.1.2",
"node-fetch": "2.6.1",
"nyc": "14.1.1",

@@ -72,3 +71,3 @@ "request": "2.87.0",

"mime-types": "2.1.18",
"minimatch": "3.0.4",
"minimatch": "3.1.2",
"path-is-inside": "1.0.2",

@@ -75,0 +74,0 @@ "path-to-regexp": "2.2.1",

# 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)
[![codecov](https://codecov.io/gh/vercel/serve-handler/branch/main/graph/badge.svg)](https://codecov.io/gh/vercel/serve-handler)
[![install size](https://packagephobia.now.sh/badge?p=serve-handler)](https://packagephobia.now.sh/result?p=serve-handler)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)
This package represents the core of [serve](https://github.com/zeit/serve). It can be plugged into any HTTP server and is responsible for routing requests and handling responses.
This package represents the core of [serve](https://github.com/vercel/serve). It can be plugged into any HTTP server and is responsible for routing requests and handling responses.

@@ -26,3 +24,3 @@ In order to customize the default behaviour, you can also pass custom routing rules, provide your own methods for interacting with the file system and much more.

Next, add it to your HTTP server. Here's an example using [micro](https://github.com/zeit/micro):
Next, add it to your HTTP server. Here's an example using [micro](https://github.com/vercel/micro):

@@ -317,19 +315,5 @@ ```js

## Use Cases
There are two environments in which [ZEIT](https://zeit.co) uses this package:
### Production
When deploying your static project to [Now](https://zeit.co/now), you can add any of the [configuration options](https://github.com/zeit/serve-handler#options) to the `static` property within `now.json` and they will be considered when handling requests to your deployment.
### Development
When testing your project on your local device, we suggest using [serve](https://github.com/zeit/serve).
Since it comes with support for `serve-handler` out of the box, you can create a `serve.json` file to customize its behavior. It will also read the configuration from `static` inside `now.json`.
## Author
Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo)) - [ZEIT](https://zeit.co)
Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo)) - [Vercel](https://vercel.com)

@@ -336,0 +320,0 @@

@@ -130,4 +130,2 @@ // Native

let cleanedUrl = false;
// By stripping the HTML parts from the decoded

@@ -139,3 +137,9 @@ // path *before* handling the trailing slash, we make

decodedPath = decodedPath.replace(matchHTML, '');
cleanedUrl = true;
if (decodedPath.indexOf('//') > -1) {
decodedPath = decodedPath.replace(/\/+/g, '/');
}
return {
target: ensureSlashStart(decodedPath),
statusCode: defaultType
};
}

@@ -168,9 +172,2 @@

if (cleanedUrl) {
return {
target: ensureSlashStart(decodedPath),
statusCode: defaultType
};
}
// This is currently the fastest way to

@@ -418,2 +415,3 @@ // iterate over an array

/* istanbul ignore next */
if (a.base < b.base) {

@@ -420,0 +418,0 @@ return -1;