Skip to content

Commit 3ad61a9

Browse files
committed
Reverted "🔥 Dropped support for "host" parameter in Content API SDK"
reverts 7fe05c1. refs https://github.com/TryGhost/Toolbox/issues/348 - This is a breaking change and should go into a major release instead of a patch release, that is planned to be done next
1 parent 64b67df commit 3ad61a9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎packages/content-api/lib/content-api.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,21 @@ const defaultMakeRequest = ({url, method, params, headers}) => {
5555
* @param {String|Boolean} options.version - a version string like v3, v4, v5 or boolean value identifying presence of Accept-Version header
5656
* @param {String|Boolean} [options.userAgent] - value controlling the 'User-Agent' header should be sent with a request
5757
* @param {Function} [options.makeRequest]
58+
* @param {String} [options.host] Deprecated
5859
*/
59-
export default function GhostContentAPI({url, key, version, userAgent, ghostPath = 'ghost', makeRequest = defaultMakeRequest}) {
60+
export default function GhostContentAPI({url, key, host, version, userAgent, ghostPath = 'ghost', makeRequest = defaultMakeRequest}) {
61+
/**
62+
* host parameter is deprecated
63+
* @deprecated use "url" instead
64+
*/
65+
if (host) {
66+
// eslint-disable-next-line
67+
console.warn(`${name}: The 'host' parameter is deprecated, please use 'url' instead`);
68+
if (!url) {
69+
url = host;
70+
}
71+
}
72+
6073
if (this instanceof GhostContentAPI) {
6174
return GhostContentAPI({url, key, version, userAgent, ghostPath, makeRequest});
6275
}

‎packages/content-api/test/content-api-test/content-api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('GhostContentApi', function () {
4242
//
4343
}
4444

45-
new GhostContentApi({url: config.url, key: config.key, version: config.version});
45+
new GhostContentApi({host: config.url, key: config.key, version: config.version});
4646
new GhostContentApi(config);
4747
});
4848

0 commit comments

Comments
 (0)