Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spec/stringProcessing/parseSynonymsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( [] );
} );
} );
4 changes: 4 additions & 0 deletions src/stringProcessing/parseSynonyms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down