김서영

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 );
......@@ -93,7 +97,10 @@ search.naver = ( keywordText ) => {
.then( ( html ) => {
result = getHtmlMain( naverMain, keywordText, html, naverURL, naver );
resolve( result );
})
})
.catch( ( err ) => {
throw new Error( err );
});
})
}
......@@ -109,7 +116,10 @@ search.google = ( keywordText ) => {
.then( ( html ) => {
result = getHtmlMain( googleMain, keywordText, html, googleURL, google );
resolve( result );
})
})
.catch( ( err ) => {
throw new Error( err );
});
})
}
......