handle missing tags correctly
parent
c193084532
commit
f13fbc452f
|
@ -22,8 +22,8 @@ module.exports = {
|
||||||
if (!body.metadata) throw new HttpError(400, 'Missing OPDS metadata')
|
if (!body.metadata) throw new HttpError(400, 'Missing OPDS metadata')
|
||||||
if (!body.metadata['@type'] || body.metadata['@type'] !== 'http://schema.org/Book') throw new HttpError(400, 'Invalid \'@type\': expected \'http://schema.org/Book\'')
|
if (!body.metadata['@type'] || body.metadata['@type'] !== 'http://schema.org/Book') throw new HttpError(400, 'Invalid \'@type\': expected \'http://schema.org/Book\'')
|
||||||
|
|
||||||
let tags = (body.metadata.tags || '').split(/,\s*/)
|
let tags = (body.metadata.tags || '').split(/,\s*/).filter(x => x.length)
|
||||||
if (!tags.length && body.metadata.title) tags = body.metadata.title.split(/\s+/).filter(x => x.length >= 3)
|
if (!tags.length && body.metadata.title) tags = body.metadata.title.replace(/[^\w\s]/g, '').split(/\s+/).filter(x => x.length >= 3)
|
||||||
const query = {
|
const query = {
|
||||||
hostname: host,
|
hostname: host,
|
||||||
title: body.metadata.title,
|
title: body.metadata.title,
|
||||||
|
|
Loading…
Reference in New Issue