Commit Graph

7 Commits

Author SHA1 Message Date
Prathamesh Gawas
3424222597
🐛 Fixed redirects with special characters (#15533)
closes: https://github.com/TryGhost/Ghost/issues/15267

- This was because the URLs were not being encoded and matched correctly - it is solved by encoding the URL before adding to the router.
2022-10-13 11:41:20 +01:00
Simon Backx
7e556d84de Fixed adding same redirect multiple times throws an error on removal (#379)
refs https://ghost.slack.com/archives/C02G9E68C/p1647599592576139

When you add a redirect multiple times, and remove it afterwards, an error is thrown:
`Cannot destructure property 'fromRegex' of 'this.redirects[redirectId]' as it is undefined.` 
This was caused by `redirectIds` that contained the same id multiple times.

* Added a test for adding a redirect multiple times and removing it once
* Fixed adding same redirect multiple times throws an error on removal
2022-03-24 09:54:19 +01:00
Naz
eb6d1b208a Made options parameter optional
refs https://github.com/TryGhost/Toolbox/issues/139

- The options parameter doesn't have to be passed in as there is handling for a default value in place - "permanent = false"
2021-11-29 16:08:03 +04:00
Naz
c44e33b1f7 Simplified DynamicRedirectManager's constructor interface
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- There is no need to pass in whole "urlUtils" instance to construct the class as all the class has to know is how to construct a "subdirectory URL" which can be a single function passed in instead of a vague object instance
2021-10-12 17:21:46 +02:00
Naz
ba2a5df493 Added handling for invalid redirect regexes
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch
refs 8f5186995d
refs 260a47da83

- The router should not stop working when an invalid redirect definition is added
- Referenced commits solve this exact problem before this module was introduced
2021-10-12 17:21:46 +02:00
Naz
80f2a001ec Simplified DynamicRedirectManager's constructor interface
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- In most of the packages we follow the pattern of passing in a single "options" object into a constructor and desructuring those the object into parameter, like this example: 077c83dc2d/packages/limit-service/lib/limit-service.js (L19-L26)
2021-10-12 17:21:46 +02:00
Fabien 'egg' O'Carroll
8c92f5744c Added express-dynamic-redirects module (#337)
refs https://github.com/TryGhost/Team/issues/1091

The Offers feature needs to be able to add and remove redirects to Ghost
- which is very similar to the custom redirects functionality. Here we've
pulled out the core of the dynamic redirect part of custom redirects so
that it can be used by both features and have code shared between them.
2021-09-29 12:01:40 +02:00