🐛 Fixed redirects to absolute URLs (#10777)

closes #10776

When the "to" property of the redirect includes a host (implying an external or fully qualified url) we skip replacing any paths and redirect straight to it, rather than modifying the URL with the sites sub-directory.
This commit is contained in:
Timothy Stapleton 2019-06-09 22:48:37 -07:00 committed by Fabien O'Carroll
parent a4f119cb7f
commit f2e60806da

View File

@ -53,7 +53,9 @@ _private.registerRoutes = () => {
const fromURL = url.parse(req.originalUrl);
const toURL = url.parse(redirect.to);
toURL.pathname = fromURL.pathname.replace(new RegExp(redirect.from, options), toURL.pathname),
toURL.pathname = (toURL.hostname)
? toURL.pathname
: fromURL.pathname.replace(new RegExp(redirect.from, options), toURL.pathname);
toURL.search = fromURL.search;
res.set({