Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connect-slashes

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-slashes - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

.travis.yml

2

lib/connect-slashes.js

@@ -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" }, {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc