unpkg/modules/middleware/redirectLegacyURLs.js

17 lines
437 B
JavaScript
Raw Normal View History

2018-05-19 15:34:36 +00:00
/**
* Redirect old URLs that we no longer support.
*/
2019-01-06 00:50:05 +00:00
export default function redirectLegacyURLs(req, res, next) {
// Permanently redirect /_meta/path to /_metadata/path
2018-05-19 15:34:36 +00:00
if (req.path.match(/^\/_meta\//)) {
return res.redirect(301, '/_metadata' + req.path.substr(6));
2018-05-19 15:34:36 +00:00
}
// Permanently redirect /path?json => /path?meta
if (req.query.json != null) {
return res.redirect(301, '/_metadata' + req.path);
2018-05-19 15:34:36 +00:00
}
next();
}