serve-handler
Advanced tools
Comparing version 6.1.2 to 6.1.3
{ | ||
"name": "serve-handler", | ||
"version": "6.1.2", | ||
"version": "6.1.3", | ||
"description": "The routing foundation of `serve` and static deployments on Now", | ||
@@ -33,5 +33,5 @@ "main": "src/index.js", | ||
"ava": "2.2.0", | ||
"codecov": "3.0.2", | ||
"codecov": "3.7.0", | ||
"commander": "2.15.1", | ||
"dot": "1.1.2", | ||
"dot": "1.1.3", | ||
"eslint": "6.1.0", | ||
@@ -38,0 +38,0 @@ "fs-extra": "6.0.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) | ||
[![Build Status](https://circleci.com/gh/vercel/serve-handler.svg?&style=shield)](https://circleci.com/gh/vercel/serve-handler) | ||
[![codecov](https://codecov.io/gh/vercel/serve-handler/branch/master/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 +25,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 +316,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 +321,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; |
42571
322