UNPKG

landmark-serve

Version:

Web Application Framework and Admin GUI / Content Management System built on Express.js and Mongoose

31 lines (24 loc) 705 B
var _ = require('underscore'), utils = require('landmark-utils'); /** * Adds one or more redirections (urls that are redirected when no matching * routes are found, before treating the request as a 404) * * #### Example: * landmark.redirect('/old-route', 'new-route'); * * // or * * landmark.redirect({ * 'old-route': 'new-route' * }); */ function redirect() { if (arguments.length === 1 && utils.isObject(arguments[0])) { _.extend(this._redirects, arguments[0]); } else if (arguments.length === 2 && 'string' === typeof arguments[0] && 'string' === typeof arguments[1]) { this._redirects[arguments[0]] = arguments[1]; } return this; }; module.exports = redirect;