mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Allowed OfferTitle to be empty
refs https://github.com/TryGhost/Team/issues/1163 This allows users to not provide a title for an Offer. We store the lack of a title as `NULL` in the DB, but we will always provide a string to the API so that the title can safely be used in HTML.
This commit is contained in:
parent
d522da5d42
commit
b6234d6e96
@ -168,8 +168,8 @@ class OfferRepository {
|
||||
id: offer.id,
|
||||
name: offer.name.value,
|
||||
code: offer.code.value,
|
||||
portal_title: offer.displayTitle.value,
|
||||
portal_description: offer.displayDescription.value,
|
||||
portal_title: offer.displayTitle.value || null,
|
||||
portal_description: offer.displayDescription.value || null,
|
||||
discount_type: offer.type.value === 'fixed' ? 'amount' : 'percent',
|
||||
discount_amount: offer.amount.value,
|
||||
interval: offer.cadence.value,
|
||||
|
@ -21,7 +21,7 @@ class OfferDescription extends ValueObject {
|
||||
});
|
||||
}
|
||||
|
||||
return new OfferDescription(description);
|
||||
return new OfferDescription(description.trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,10 @@ const InvalidOfferTitle = require('../errors').InvalidOfferTitle;
|
||||
class OfferTitle extends ValueObject {
|
||||
/** @param {unknown} title */
|
||||
static create(title) {
|
||||
if (!title || typeof title !== 'string') {
|
||||
if (title === null || title === undefined) {
|
||||
return new OfferTitle('');
|
||||
}
|
||||
if (typeof title !== 'string') {
|
||||
throw new InvalidOfferTitle({
|
||||
message: 'Offer `display_title` must be a string.'
|
||||
});
|
||||
@ -17,7 +20,7 @@ class OfferTitle extends ValueObject {
|
||||
});
|
||||
}
|
||||
|
||||
return new OfferTitle(title);
|
||||
return new OfferTitle(title.trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user