0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Updated Tier welcomePageURL to be a string rather than URL

refs https://github.com/TryGhost/Team/issues/2078

We allow passing in relative URLs for the welcome page, so we need to accept a
string for this property.
This commit is contained in:
Fabien "egg" O'Carroll 2022-10-20 11:48:16 +07:00
parent b607bee27f
commit 581164ed60

View file

@ -41,7 +41,7 @@ module.exports = class Tier {
this.#description = validateDescription(value); this.#description = validateDescription(value);
} }
/** @type {URL} */ /** @type {string} */
#welcomePageURL; #welcomePageURL;
get welcomePageURL() { get welcomePageURL() {
return this.#welcomePageURL; return this.#welcomePageURL;
@ -243,20 +243,15 @@ function validateName(value) {
} }
function validateWelcomePageURL(value) { function validateWelcomePageURL(value) {
if (value instanceof URL) {
return value;
}
if (!value) { if (!value) {
return null; return null;
} }
try { if (value === null || typeof value === 'string') {
return new URL(value); return value;
} catch (err) {
throw new ValidationError({
err,
message: 'Tier Welcome Page URL must be a URL'
});
} }
throw new ValidationError({
message: 'Tier Welcome Page URL must be a string'
});
} }
function validateDescription(value) { function validateDescription(value) {