Commit Graph

6 Commits

Author SHA1 Message Date
Hannah Wolfe
5b43d82742 Improved types in config-url-helpers 2021-06-17 13:53:09 +01:00
Hannah Wolfe
eb829a050b Prepared config-url-helpers for their intended use
- added getSubdir, getSiteUrl and getAdminUrl methods from url-utils
- refactored them so they are designed to be bound by nconf
- exposed a bindAll method
- moved over the tests and refactor from a class instance to nconf bindings
2021-06-17 11:41:50 +01:00
Hannah Wolfe
f98bcf150c Merged deduplicate subdirectory util from SDK/url-utils 2021-06-16 17:55:14 +01:00
Hannah Wolfe
0d965276a1 Added new config-url-helpers package
- This will contain a small number of helpers for getting correctly formatted urls from config
2021-06-16 17:54:30 +01:00
Kevin Ansfield
523278b295 🐛 Fixed subdirectory handling and deduplication
no issue

Ghost's relative->absolute handling is a little strange when the rootUrl includes a subdirectory. Root-relative paths such as /content/image.jpg are actually treated as subdirectory-relative. This means that it's possible to migrate from a root config to a subdirectory config without migrating data in the database, _however_ that means that the database will now have a mix of path styles (/content/image.png and /subdir/content/image.png). To handle this when all root-relative paths are treated as subdir-relative we have to rely on subdirectory deduplication.

- updates tests to reflect correct subdirectory handling according to the above rules
- fixes missing subdirectories when root urls contain subdirectories but relative paths do not
- fixes subdirectory deduplication when the supplied url/path does not have a trailing slash but matches the root url's subdirectory
2019-10-02 12:33:34 +01:00
Kevin Ansfield
86343f028b Refactored url-utils (#141)
no issue

- extracted most standalone util functions into separate files+tests
- switched the main `UrlUtils` function into a class (we had mixed uses of the returned object previously as both `urlUtils()` and `new UrlUtils()` - the class makes it obvious that the `new` keyword is required)
- removed some unnecessary use of lodash and switched to using `URL` in place of `url` so that the package can have parity across node+browser without needing an additional package bundled in
2019-08-12 08:57:13 +01:00