mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛Fixed custom redirects to forward hashes correctly (#10319)
closes #10290
This commit is contained in:
parent
a1f0169edf
commit
418e958c69
1 changed files with 10 additions and 3 deletions
|
@ -22,6 +22,13 @@ _private.registerRoutes = () => {
|
|||
validation.validateRedirects(redirects);
|
||||
|
||||
redirects.forEach((redirect) => {
|
||||
/**
|
||||
* Extract target info, such as hash.
|
||||
*
|
||||
* Required to re-formulate the correct endpoint.
|
||||
*/
|
||||
const parsedTo = url.parse(redirect.to);
|
||||
|
||||
/**
|
||||
* Detect case insensitive modifier when regex is enclosed by
|
||||
* / ... /i
|
||||
|
@ -55,10 +62,10 @@ _private.registerRoutes = () => {
|
|||
res.set({
|
||||
'Cache-Control': `public, max-age=${maxAge}`
|
||||
});
|
||||
|
||||
res.redirect(redirect.permanent ? 301 : 302, url.format({
|
||||
pathname: parsedUrl.pathname.replace(new RegExp(redirect.from, options), redirect.to),
|
||||
search: parsedUrl.search
|
||||
pathname: parsedUrl.pathname.replace(new RegExp(redirect.from, options), parsedTo.pathname),
|
||||
search: parsedUrl.search,
|
||||
hash: parsedTo.hash
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue