
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
connect-slashes
Advanced tools
Trailing slash redirect middleware for Connect and Express.js. Useful for creating canonical urls in your Node.js applications.
$ npm install connect-slashes
var connect = require("connect")
, slashes = require("connect-slashes");
connect()
.use(connect.logger())
.use(connect.static())
.use(slashes())
.listen(3000);
Alternatively, you can pass false
as the first argument to .slashes()
in order to remove trailing slashes instead of appending them:
.use(slashes(false));
You can also pass a second argument with an options object. For example, if an application is behind a reverse proxy server that removes part of the URL (a base_path) before proxying to the application, then the base
can be specified with an option:
.use(slashes(true, { base: "/blog" })); // prepends a base url to the redirect
By default, all redirects are using the 301 Moved Permanently header. You can change this behavior by passing in the optional code
option:
.use(slashes(true, { code: 302 })); // 302 Temporary redirects
You can also set additional headers to the redirect response with the headers
option:
.use(slashes(true, { headers: { "Cache-Control": "public" } }));
.use()
this middleware only after the connect.static()
middleware.MIT
FAQs
Trailing slash redirect middleware for Connect and Express.js
The npm package connect-slashes receives a total of 11,534 weekly downloads. As such, connect-slashes popularity was classified as popular.
We found that connect-slashes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.