From 4dcaf0670b52d7066d5897458b601c0289b86a24 Mon Sep 17 00:00:00 2001 From: Serge Huijben Date: Fri, 23 Oct 2015 13:22:50 +0200 Subject: [PATCH 1/3] fix bug #28 check if opts.content is of type string before calling .match on it to prevent errors --- src/partials.plugin.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partials.plugin.coffee b/src/partials.plugin.coffee index 17a2cad..f780ee8 100644 --- a/src/partials.plugin.coffee +++ b/src/partials.plugin.coffee @@ -219,7 +219,7 @@ module.exports = (BasePlugin) -> # Check partialContainerRegex = /\[partial:([^\]]+)\]/g - partialContainers = (opts.content or '').match(partialContainerRegex) or [] + partialContainers = typeof opts.content === 'string' ? opts.content.match(partialContainerRegex) : [] return next() if partialContainers.length is 0 filePath = file.getFilePath() From f225ecaf00defeac4e8fd9b625b8339fea933add Mon Sep 17 00:00:00 2001 From: Serge Huijben Date: Fri, 23 Oct 2015 13:44:38 +0200 Subject: [PATCH 2/3] make it coffeescript use coffeescript syntax --- src/partials.plugin.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partials.plugin.coffee b/src/partials.plugin.coffee index f780ee8..0ec941c 100644 --- a/src/partials.plugin.coffee +++ b/src/partials.plugin.coffee @@ -219,7 +219,7 @@ module.exports = (BasePlugin) -> # Check partialContainerRegex = /\[partial:([^\]]+)\]/g - partialContainers = typeof opts.content === 'string' ? opts.content.match(partialContainerRegex) : [] + partialContainers = if typeof opts.content is 'string' then opts.content.match(partialContainerRegex) else [] return next() if partialContainers.length is 0 filePath = file.getFilePath() From 142da7bb92a7fc8e0fe92f30808d3371d21a9ec1 Mon Sep 17 00:00:00 2001 From: Serge Huijben Date: Fri, 23 Oct 2015 14:01:19 +0200 Subject: [PATCH 3/3] check against null or undefined check if partialContainers is defined --- src/partials.plugin.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partials.plugin.coffee b/src/partials.plugin.coffee index 0ec941c..2ba0e66 100644 --- a/src/partials.plugin.coffee +++ b/src/partials.plugin.coffee @@ -220,7 +220,7 @@ module.exports = (BasePlugin) -> # Check partialContainerRegex = /\[partial:([^\]]+)\]/g partialContainers = if typeof opts.content is 'string' then opts.content.match(partialContainerRegex) else [] - return next() if partialContainers.length is 0 + return next() if not partialContainers? or partialContainers.length is 0 filePath = file.getFilePath() # Prepare