4finance-redirect-url

0.2.1 • Public • Published

Redirect URL

Redirect URL is an express middleware for redirection with slashes at the end of the URL path and for redirecting old urls by new ones.

Old to new URL redirections should be used in older projects where contentful redirections are not present.

yarn add 4finance-redirect-url

Motivation

We would like to be able to use an unified workflow for redirections.

How to use

To use Redirect URL you need just to import fillSlash and redirect to use it as an express middleware. For client side, import withSlashes and wrap router history with that.

Example

client.js

...
import { withSlashes } from '4finance-redirect-url';

const appHistory = withSlashes(useRouterHistory(createBrowserHistory)());
...

server.js

...
import { fillSlash, redirect } from '4finance-redirect-url'

const redirections = {
  '/old-url/': '/new-url/',
};
const app = express();

app.use(redirect(redirections));
app.use(fillSlash);
...

Changelog

0.2.1 - Fix not sending next after redirect 0.2.0 - Add fillSlashWithIgnore method for adding slashes at the end of the url but keep url from ignore list without change

0.2.*

0.1.1 - Fix path in redirection 0.1.0 - Add support for client side slash inserting

0.1.*

Readme

Keywords

Package Sidebar

Install

npm i 4finance-redirect-url

Weekly Downloads

6

Version

0.2.1

License

none

Last publish

Collaborators

  • jakub.kottnauer