serve-handler
Advanced tools
Comparing version 2.3.8 to 2.3.9
{ | ||
"name": "serve-handler", | ||
"version": "2.3.8", | ||
"version": "2.3.9", | ||
"description": "The routing foundation of `serve` and static deployments on Now", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -74,13 +74,15 @@ # serve-handler | ||
Assuming this is `true`, all `.html` and `.htm` files can be accessed without their extension (shown below). | ||
By default, all `.html` and `.htm` files can be accessed without their extension. | ||
If one of these extensions is used at the end of a filename, it will automatically perform a redirect with status code [301](https://en.wikipedia.org/wiki/HTTP_301) to the same path, but with the extension dropped. | ||
You can disable the feature like follows: | ||
```json | ||
{ | ||
"cleanUrls": true | ||
"cleanUrls": false | ||
} | ||
``` | ||
However, you can also restrict this behavior to certain paths: | ||
However, you can also restrict it to certain paths: | ||
@@ -87,0 +89,0 @@ ```json |
@@ -93,3 +93,3 @@ // Native | ||
const defaultType = 301; | ||
const matchHTML = /.html|.htm|\/index/g; | ||
const matchHTML = /(\.html|\.htm|\/index)$/g; | ||
@@ -188,21 +188,20 @@ let cleanedUrl = false; | ||
const applicable = (decodedPath, configEntry, negative) => { | ||
let matches = negative ? false : true; | ||
const applicable = (decodedPath, configEntry) => { | ||
if (typeof configEntry === 'boolean') { | ||
return configEntry; | ||
} | ||
if (typeof configEntry !== 'undefined') { | ||
matches = (configEntry === !matches); | ||
if (Array.isArray(configEntry)) { | ||
for (let index = 0; index < configEntry.length; index++) { | ||
const source = configEntry[index]; | ||
if (!matches && Array.isArray(configEntry)) { | ||
// This is much faster than `.some` | ||
for (let index = 0; index < configEntry.length; index++) { | ||
const source = configEntry[index]; | ||
if (sourceMatches(source, decodedPath)) { | ||
matches = true; | ||
} | ||
if (sourceMatches(source, decodedPath)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
return matches; | ||
return true; | ||
}; | ||
@@ -276,3 +275,3 @@ | ||
if (directoryListing === false || !applicable(relativePath, directoryListing, false)) { | ||
if (!applicable(relativePath, directoryListing)) { | ||
return null; | ||
@@ -392,3 +391,3 @@ } | ||
const decodedPath = decodeURIComponent(url.parse(request.url).pathname); | ||
const cleanUrl = applicable(decodedPath, config.cleanUrls, true); | ||
const cleanUrl = applicable(decodedPath, config.cleanUrls); | ||
const redirect = shouldRedirect(decodedPath, config, cleanUrl); | ||
@@ -395,0 +394,0 @@ |
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
251
29838
433