1.0.0 • Published 2 years ago

@omegion1npm/officiis-eius-suscipit v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@omegion1npm/officiis-eius-suscipit

@omegion1npm/officiis-eius-suscipit

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

Installation

$ npm install @omegion1npm/officiis-eius-suscipit

Usage

var connect = require("connect")
  , slashes = require("@omegion1npm/officiis-eius-suscipit");

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

sliceassertshrinkwrapescapermdirfpstylingbreakUnderscoreconfigurablepicomatchnumberregexsymbolsjQueryes6statelessmrupackagesqsObject.entriesnopelesscsswatchingES2015BigInt64Arrayexpresstypanionauthentication256dataviewform-validationdependenciesrequestpropargparsehelpersvarSymbolmapweakmapcall-boundopenless.jsenumerablelinewrapObject.valuescore-jsparsersomequerygradients css3bluebirdtrimStartStreamscompile lessHyBiprivate datalook-upreadauthassertionautoprefixeruninstallreal-timeutilbyteLengtharktypeInt16ArrayajvWebSocketsjscodesrm -rfdescriptionpositivesuperstructtoSortedindicatorpoint-freedatastructureTypeBoxmkdirpES2020clijsdomWeakMapassertstslibdeletestartersameValueZeroperformanceeventses-shimsefficientresolveglobprotobufkarmabyteOffset-0invariantES2021validatorhashvaluesfixed-widthcollection.es6Object.getPrototypeOfoutputlinkinstallerchromestdlibrecursivegradients cssES8avaECMAScript 5ECMAScript 2017bootstrap csstypedarrayeslintconfigserializationECMAScript 2018pyyamlfindLastIndexpathbuffersdatestreams2nested cssES2023safeESnextscheme-validationURLSearchParamsequalarray__proto__listenersbindjsonpathObservableRegExp.prototype.flagssetterless cssdescriptorsparentsuser-streamsjasminecss-in-jsless mixinsawesomesaucesharedarraybufferstyletextguidECMAScript 2015processMicrosoftIteratordescriptorwaapisigterminternal slotArray.prototype.flattenhttpgroupByFloat64ArrayxtermtddcolorsBigUint64ArraylruwarningconfigInt8Arrayargumentreact posefantasy-landbundlerenvchannelconstthroatbannergesturesmakeurlESpropertyl10nWeakSetconsolecss lessArray.prototype.findLastIndex0es5typeerrordotenvapolloirqsymlinksserializertypesramdajoirm -frpasswordlazyES6vestes7RxJSsetPrototypeOfECMAScript 2019YAMLnegative zeroaccessorvalidatesignalsrgbString.prototype.trimmetadataintrinsicargvtacitsymboltypeofimmerwatchFilecryptfastdefinesortedURLUint8ArraysanitizationloadingRFC-6455takewgetMapanimationtesterspinnerhooksES2019Pushlogerror-handlingquotetoolsexitprunejson-schema-validationcallObject.assignfindforEachfunctionaltrimEndgdprutil.inspectperformantunicodebddArray.prototype.includesoffsetsharedhttpsgetopttoolkitStyleSheettestingtraversees8corsminimalfast-cloneprototypeharmonysearchnamesfsescheckinferencewaitUint8ClampedArrayinstallproperties
1.0.0

2 years ago