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