From c193084532c119dd738e24535248d61891835a7d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 May 2019 19:01:54 -0400 Subject: [PATCH 1/2] >, not < --- api/controllers/BooksController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/controllers/BooksController.js b/api/controllers/BooksController.js index 1c2ed2c..6680325 100644 --- a/api/controllers/BooksController.js +++ b/api/controllers/BooksController.js @@ -23,14 +23,14 @@ module.exports = { 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*/) - 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.split(/\s+/).filter(x => x.length >= 3) const query = { hostname: host, title: body.metadata.title, author: body.metadata.author, publisher: body.metadata.publisher, identifier: body.metadata.identifier, - tags: JSON.stringify(tags), + tags: JSON.stringify(tags || []), version: body.metadata.modified.replace(/\D/g, '') } From f13fbc452f01e393179f355b119c147899273b40 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 May 2019 19:19:07 -0400 Subject: [PATCH 2/2] handle missing tags correctly --- api/controllers/BooksController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/controllers/BooksController.js b/api/controllers/BooksController.js index 6680325..6b1b7ff 100644 --- a/api/controllers/BooksController.js +++ b/api/controllers/BooksController.js @@ -22,8 +22,8 @@ module.exports = { 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\'') - let tags = (body.metadata.tags || '').split(/,\s*/) - if (!tags.length && body.metadata.title) tags = body.metadata.title.split(/\s+/).filter(x => x.length >= 3) + let tags = (body.metadata.tags || '').split(/,\s*/).filter(x => x.length) + if (!tags.length && body.metadata.title) tags = body.metadata.title.replace(/[^\w\s]/g, '').split(/\s+/).filter(x => x.length >= 3) const query = { hostname: host, title: body.metadata.title,