diff --git a/ghost/core/core/server/services/members/content-gating.js b/ghost/core/core/server/services/members/content-gating.js index 6a63a45521..69e153475e 100644 --- a/ghost/core/core/server/services/members/content-gating.js +++ b/ghost/core/core/server/services/members/content-gating.js @@ -46,7 +46,7 @@ function checkPostAccess(post, member) { return BLOCK_ACCESS; } visibility = post.tiers.map((product) => { - return `product:${product.slug}`; + return `product:'${product.slug}'`; }).join(','); } diff --git a/ghost/core/test/unit/server/services/members/content-gating.test.js b/ghost/core/test/unit/server/services/members/content-gating.test.js index de40bc0ca0..fdd9228dfc 100644 --- a/ghost/core/test/unit/server/services/members/content-gating.test.js +++ b/ghost/core/test/unit/server/services/members/content-gating.test.js @@ -44,6 +44,15 @@ describe('Members Service - Content gating', function () { should(access).be.true(); }); + it('should not error out if the slug associated with a tier is only 1 character in length', async function () { + post = {visibility: 'tiers', tiers: [{slug: 'x'}]}; + member = {id: 'test', status: 'paid', products: [{ + slug: 'x' + }]}; + + (() => checkPostAccess(post, member)).should.not.throw(); + }); + it('should block access to members only post without member', async function () { post = {visibility: 'members'}; member = null;