Get tests passing again

This commit is contained in:
Michael Jackson
2019-07-09 17:21:25 -07:00
parent 2e3c9ff526
commit f3ecddea47
42 changed files with 309 additions and 305 deletions

View File

@ -1,15 +1,20 @@
import createSearch from '../utils/createSearch.js';
/**
* Redirect old URLs that we no longer support.
*/
export default function redirectLegacyURLs(req, res, next) {
// Permanently redirect /_meta/path to /_metadata/path
// Permanently redirect /_meta/path to /path?meta
if (req.path.match(/^\/_meta\//)) {
return res.redirect(301, '/_metadata' + req.path.substr(6));
req.query.meta = '';
return res.redirect(301, req.path.substr(6) + createSearch(req.query));
}
// Permanently redirect /path?json => /path?meta
if (req.query.json != null) {
return res.redirect(301, '/_metadata' + req.path);
delete req.query.json;
req.query.meta = '';
return res.redirect(301, req.path + createSearch(req.query));
}
next();