From acc82d850ce6930a99bd2bd5b391e9ded3ded4a2 Mon Sep 17 00:00:00 2001 From: Ed Horsford Date: Tue, 4 Jun 2019 20:15:00 +0100 Subject: [PATCH 1/3] Check for empty tags Fixes #556 --- src/TemplateData.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/TemplateData.js b/src/TemplateData.js index 501553aef..84e3acee8 100644 --- a/src/TemplateData.js +++ b/src/TemplateData.js @@ -338,8 +338,13 @@ class TemplateData { } static cleanupData(data) { - if ("tags" in data && typeof data.tags === "string") { - data.tags = data.tags ? [data.tags] : []; + if ("tags" in data){ + if (typeof data.tags === "string"){ + data.tags = data.tags ? [data.tags] : []; + } + if (data.tags === null){ + data.tags = [] + } } return data; From bb34faac22da3258833ebeaad55d967ff2ff8bb0 Mon Sep 17 00:00:00 2001 From: Ed Horsford Date: Tue, 4 Jun 2019 21:05:24 +0100 Subject: [PATCH 2/3] refactor null check --- src/TemplateData.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/TemplateData.js b/src/TemplateData.js index 84e3acee8..7ad390616 100644 --- a/src/TemplateData.js +++ b/src/TemplateData.js @@ -339,12 +339,9 @@ class TemplateData { static cleanupData(data) { if ("tags" in data){ - if (typeof data.tags === "string"){ + if (typeof data.tags === "string" || data.tags === null){ data.tags = data.tags ? [data.tags] : []; } - if (data.tags === null){ - data.tags = [] - } } return data; From 470eee8e183edf415df0b77aa5564080f9e1a9d8 Mon Sep 17 00:00:00 2001 From: Ed Horsford Date: Wed, 12 Jun 2019 12:20:32 +0100 Subject: [PATCH 3/3] Make update more readable --- src/TemplateData.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TemplateData.js b/src/TemplateData.js index 7ad390616..a3df667ef 100644 --- a/src/TemplateData.js +++ b/src/TemplateData.js @@ -339,9 +339,12 @@ class TemplateData { static cleanupData(data) { if ("tags" in data){ - if (typeof data.tags === "string" || data.tags === null){ + if (typeof data.tags === "string"){ data.tags = data.tags ? [data.tags] : []; } + else if (data.tags === null){ + data.tags = [] + } } return data;