0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/web/shared/middlewares
Fabien O'Carroll c5b8dab523 🐛 Fixed custom redirects for subdirectory setups
no-issue

This issue only occurs when using custom redirects with a subdirectory
setup, and the path to be redirected from is expressed as a regex, and
the url that is being redirected to is not an external url.

The issue has a few components:

- Redirect paths as a regex generally use the ^ to ensure that they
  match the beginning of the path.

- The path that the regex is matched against conditionally excludes the
  subdirectory, specifically, the subdirectory is excluded for external
  urls

These combined means you end up with a regex like /^\/custom-redirect/
and a path like /subdir/custom-redirect, these will not match/replace
correctly, and you'll end in an infinite redirect loop.

The fix here is to *always* remove the subdirectory when testing regex's
and then conditionally adding it back *only* for the redirect, and only
if it is an internal redirect
2020-06-16 10:24:13 +02:00
..
api Moved core/server/lib/common/logging to core/shared/logging (#11857) 2020-05-28 19:30:23 +01:00
brute.js Added brute protection to content api (#10343) 2019-01-07 20:03:46 +07:00
cache-control.js Refactored cache-control mw to remove dependencies 2020-04-22 18:01:01 +01:00
custom-redirects.js 🐛 Fixed custom redirects for subdirectory setups 2020-06-16 10:24:13 +02:00
error-handler.js Moved config from server to shared (#11850) 2020-05-27 18:47:53 +01:00
index.js Moved normalize image mw into api app 2020-04-22 17:48:54 +01:00
labs.js Swapped common for @tryghost/errors in core/server/web 2020-04-09 19:40:00 +01:00
maintenance.js Moved config from server to shared (#11850) 2020-05-27 18:47:53 +01:00
pretty-urls.js Moved config from server to shared (#11850) 2020-05-27 18:47:53 +01:00
uncapitalise.js Moved core/server/lib/url-utils to core/shared/url-utils (#11856) 2020-05-28 11:57:02 +01:00
url-redirects.js Moved core/server/lib/url-utils to core/shared/url-utils (#11856) 2020-05-28 11:57:02 +01:00