Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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( [] );
} );
it( "Should keep double quotation marks, which are needed to figure out if morphological analysis should be performed", function() {
expect( parseSynonyms( "\"Item 1\", item 2, item 3" ) ).toEqual( [ "\"Item 1\"", "item 2", "item 3" ] );
Expand Down
6 changes: 5 additions & 1 deletion packages/yoastseo/src/stringProcessing/parseSynonyms.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import removePunctuationExceptQuotes from "../stringProcessing/removePunctuation
*
* @returns {Array} An array with all synonyms.
*/
export default function( synonyms ) {
module.exports = function( synonyms ) {
if ( typeof synonyms !== "string" ) {
synonyms = "";
}

let synonymsSplit = synonyms.split( "," );

synonymsSplit = synonymsSplit.map( function( synonym ) {
Expand Down