diff --git a/spec/stringProcessing/parseSynonymsSpec.js b/spec/stringProcessing/parseSynonymsSpec.js index 2eccf5100..2d394a3b8 100644 --- a/spec/stringProcessing/parseSynonymsSpec.js +++ b/spec/stringProcessing/parseSynonymsSpec.js @@ -9,5 +9,6 @@ describe( "A test for parsing a comma-separated list of synonyms into an array o expect( parseSynonyms( "!, ,?" ) ).toEqual( [] ); expect( parseSynonyms( "To be, or not to be, that is the question:" ) ).toEqual( [ "To be", "or not to be", "that is the question" ] ); expect( parseSynonyms( "To be,or not to be,that is the question:" ) ).toEqual( [ "To be", "or not to be", "that is the question" ] ); + expect( parseSynonyms( null ) ).toEqual( [] ); } ); } ); diff --git a/src/stringProcessing/parseSynonyms.js b/src/stringProcessing/parseSynonyms.js index ad6c06901..ff69cd88e 100644 --- a/src/stringProcessing/parseSynonyms.js +++ b/src/stringProcessing/parseSynonyms.js @@ -11,6 +11,10 @@ const removePunctuation = require( "../stringProcessing/removePunctuation.js" ); * @returns {Array} An array with all synonyms. */ module.exports = function( synonyms ) { + if ( typeof synonyms !== "string" ) { + synonyms = ""; + } + let synonymsSplit = synonyms.split( "," ); synonymsSplit = synonymsSplit.map( function( synonym ) {