김서영

search.js add error check

......@@ -63,8 +63,12 @@ const searchToResult = (searchResult, result, keywordCheck) => {
result.push( searchResult );
}
} else if( keywordCheck ) {
}}
// 공백 제거하고 비교
if( result[ result.length - 1 ].passage.replace( /\s/g, '' ) !== searchResult.passage.replace( /\s/g, '' ) ) {
result.push( searchResult );
}
}
}
const getHtmlMain = ( main, keywordText, html, defaultURL, findSearchResult ) => {
const $ = cheerio.load( html );
......@@ -94,6 +98,9 @@ search.naver = ( keywordText ) => {
result = getHtmlMain( naverMain, keywordText, html, naverURL, naver );
resolve( result );
})
.catch( ( err ) => {
throw new Error( err );
});
})
}
......@@ -110,6 +117,9 @@ search.google = ( keywordText ) => {
result = getHtmlMain( googleMain, keywordText, html, googleURL, google );
resolve( result );
})
.catch( ( err ) => {
throw new Error( err );
});
})
}
......