connect-slashes
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -40,3 +40,3 @@ /** | ||
if ( "GET" == req.method ) { | ||
if ( "GET" == req.method || "HEAD" == req.method || "OPTIONS" == req.method ) { | ||
// Use originalUrl when defined ( for express compatibility); | ||
@@ -43,0 +43,0 @@ var url = (req.originalUrl || req.url).split( reQuery ) |
{ | ||
"name": "connect-slashes", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Trailing slash redirect middleware for Connect and Express.js", | ||
"keywords": [ "trailing", "slash", "connect", "middleware", "express" ], | ||
"keywords": [ | ||
"trailing", | ||
"slash", | ||
"connect", | ||
"middleware", | ||
"express" | ||
], | ||
"author": "Roi Avinoam <avinoamr@gmail.com>", | ||
@@ -16,3 +22,3 @@ "contributors": [ | ||
"devDependencies": { | ||
"mocha": "~1.14.0" | ||
"mocha": "^5.2.0" | ||
}, | ||
@@ -19,0 +25,0 @@ "scripts": { |
@@ -18,6 +18,5 @@ connect-slashes | ||
connect() | ||
.use(connect.logger()) | ||
connect() // or express() | ||
.use(connect.static()) | ||
.use(slashes()) | ||
.use(slashes()) // must come after static middleware! | ||
.listen(3000); | ||
@@ -54,3 +53,3 @@ ``` | ||
1. Only GET requests will be redirected (to avoid losing POST/PUT data) | ||
1. Only GET, HEAD, and OPTIONS requests will be redirected (to avoid losing POST/PUT data) | ||
2. This middleware will append or remove a trailing slash to all request urls. This includes filenames (/app.css => /app.css/), so it may break your static files. Make sure to `.use()` this middleware only after the `connect.static()` middleware. | ||
@@ -57,0 +56,0 @@ |
@@ -40,2 +40,26 @@ var slashes = require( ".." ), | ||
// | ||
it( "should append slashes for HEAD requests", function( done ) { | ||
append( { method: "HEAD", url: "/foo" }, { | ||
writeHead: function( status, headers ) { | ||
assert( "/foo/" == headers.Location ); | ||
}, | ||
end: done | ||
}, function() { | ||
assert( false ); // no redirect took place | ||
} ); | ||
}); | ||
// | ||
it( "should append slashes for OPTIONS requests", function( done ) { | ||
append( { method: "OPTIONS", url: "/foo" }, { | ||
writeHead: function( status, headers ) { | ||
assert( "/foo/" == headers.Location ); | ||
}, | ||
end: done | ||
}, function() { | ||
assert( false ); // no redirect took place | ||
} ); | ||
}); | ||
// | ||
it( "should append slashes for GET requests using originalUrl", function( done ) { | ||
@@ -42,0 +66,0 @@ append( { method: "GET", originalUrl: "/foo" }, { |
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
13058
247
58