@tryghost/url-utils
v5.5.1
Published
Maintainers
Keywords
Readme
Url Utils
Install
npm install @tryghost/url-utils --save
or
yarn add @tryghost/url-utils
Usage
Admin origin
getAdminOrigin() returns the origin (protocol, host and port) of the admin URL, falling back to the site URL when no admin URL is configured:
urlUtils.getAdminOrigin(); // 'https://admin.example.com'Freezing URLs
When the site, subdirectory and admin URLs never change at runtime (e.g. in production), mark them as frozen so url-utils can skip calling the URL getters:
const urlUtils = new UrlUtils({getSiteUrl, getSubdir, getAdminUrl, frozen: true});
// or at any time after creation
urlUtils.freeze();
// restore the original getters (e.g. after changing config in tests)
urlUtils.unfreeze();While frozen, getSiteUrl(), getSubdir() and getAdminUrl() return the values captured at freeze time. Calling freeze() again re-captures the current values.
Develop
This is a monorepo managed with Nx.
Follow the instructions for the top-level repo.
git clonethis repo &cdinto it as usual- Run
pnpm installto install top-level dependencies.
Run
pnpm dev
Test
pnpm lintrun just eslintpnpm testrun lint and tests
Copyright & License
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license.
