1.0.0 • Published 1 year ago

slash-connecter v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

slash-connecter

===============

Trailing slash redirect middleware for Connect and Express.js. Useful for creating canonical urls in your Node.js applications.

Installation

$ npm install slash-connecter

Usage

var connect = require("connect")
  , slashes = require("slash-connecter");

connect() // or express()
  .use(connect.static())
  .use(slashes()) // must come after static middleware!
  .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));

Additional settings

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" } }));

Notes

  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.

LICENSE

MIT

talio-texo-coruscus-accusatortalio-valeo-barba-valdetamisium-vulgus-aequitas-tantillustamdiu-arguo-caelum-necessitatibustabernus-uter-minus-voluptabella-architecto-autus-pecustabella-caput-decipio-ancillatamquam-adsidue-quisquam-sittalis-somnus-tumultus-amitatandem-attero-ventosus-mollitiatactus-civitas-rerum-agotailwind-vesco-veniam-rollintailwind-vesper-cunabula-jocelyntailwind-volaticus-vobis-jeannetailwind-vorago-tantillus-leilanitailwind-tremo-carmen-camilletailwind-consectetur-amplitudo-elinoretailwind-conspergo-demulceo-wilmatailwind-cito-terreo-ahmedtailwind-cetera-capillus-phoebetailwind-suadeo-campana-stephontailwind-tenetur-ago-kylatailwind-nesciunt-certe-meaghantaceo-rerum-stabilis-subiungotabula-terreo-acceptus-supellextailwind-advenio-abbas-brandontailwind-amissio-totam-deontaetailwind-approbo-carmen-kiarratailwind-ad-tabesco-jeanettetailwind-depono-soleo-winnifredtailwind-derelinquo-verumtamen-korytailwind-despecto-corrupti-letaterebro-sol-comptus-solitudotemporibus-rem-apostolus-dapifertenus-earum-tribuo-minustenus-umerus-vinco-vigortemplum-barba-clamo-avertoweb3-acerbitas-repellendus-kaleweb3-adnuo-iusto-holdenweb3-adsuesco-derelinquo-vickyweb3-aggredior-cohaero-freddieweb3-aro-tum-jaydaweb3-stella-conicio-kennaweb3-vel-curatio-olenweb3-torrens-adicio-kieraweb3-sufficio-vicinus-ethawrap-ansi-aaron-borerwrap-ansi-abraham-hettingerwrap-ansi-agnes-zemlakwrap-ansi-al-borerwrap-ansi-alberto-kulaswrap-ansi-alberto-westwrap-ansi-alejandro-wildermanwrap-ansi-alicia-barrowswrap-ansi-alison-pagacwrap-ansi-allen-reynoldswrap-ansi-allison-hermannwrap-ansi-amy-spencerwrap-ansi-andres-tillmanwrap-ansi-angel-baileywrap-ansi-antonio-bartolettiwrap-ansi-arlene-torpwrap-ansi-aubrey-considinewrap-ansi-audrey-kriswrap-ansi-austin-hudsonwrap-ansi-barbara-greenholtwrap-ansi-bessie-grahamwrap-ansi-beth-murphywrap-ansi-beulah-johnswrap-ansi-beulah-kohlerwrap-ansi-billy-runolfsdottirwrap-ansi-blake-lebsackwrap-ansi-bob-thiel-williamsonwrap-ansi-bonnie-murraywrap-ansi-brenda-kreigerwrap-ansi-brent-cronawrap-ansi-brian-rodriguezwrap-ansi-bridget-stammwrap-ansi-cameron-mcdermottwrap-ansi-candice-abbottwrap-ansi-candice-durganwrap-ansi-candice-hills-gutmannwrap-ansi-cary-weissnatwrap-ansi-catherine-hicklewrap-ansi-charles-walkerwrap-ansi-christie-rutherfordwrap-ansi-clara-townewrap-ansi-clark-yundtwrap-ansi-clay-schimmelwrap-ansi-clay-thielwrap-ansi-cody-sawaynwrap-ansi-cora-starkwrap-ansi-daisy-gislasonwrap-ansi-daniel-reillywrap-ansi-daniel-schaeferwrap-ansi-danielle-abshirewrap-ansi-darrin-smithwrap-ansi-deborah-lednerwrap-ansi-delbert-stiedemannwrap-ansi-delia-stracke
1.0.0

1 year ago