- 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
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
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