Showing
1 changed file
with
14 additions
and
4 deletions
... | @@ -63,8 +63,12 @@ const searchToResult = (searchResult, result, keywordCheck) => { | ... | @@ -63,8 +63,12 @@ const searchToResult = (searchResult, result, keywordCheck) => { |
63 | result.push( searchResult ); | 63 | result.push( searchResult ); |
64 | } | 64 | } |
65 | } else if( keywordCheck ) { | 65 | } else if( keywordCheck ) { |
66 | - | 66 | + // 공백 제거하고 비교 |
67 | -}} | 67 | + if( result[ result.length - 1 ].passage.replace( /\s/g, '' ) !== searchResult.passage.replace( /\s/g, '' ) ) { |
68 | + result.push( searchResult ); | ||
69 | + } | ||
70 | + } | ||
71 | +} | ||
68 | 72 | ||
69 | const getHtmlMain = ( main, keywordText, html, defaultURL, findSearchResult ) => { | 73 | const getHtmlMain = ( main, keywordText, html, defaultURL, findSearchResult ) => { |
70 | const $ = cheerio.load( html ); | 74 | const $ = cheerio.load( html ); |
... | @@ -93,7 +97,10 @@ search.naver = ( keywordText ) => { | ... | @@ -93,7 +97,10 @@ search.naver = ( keywordText ) => { |
93 | .then( ( html ) => { | 97 | .then( ( html ) => { |
94 | result = getHtmlMain( naverMain, keywordText, html, naverURL, naver ); | 98 | result = getHtmlMain( naverMain, keywordText, html, naverURL, naver ); |
95 | resolve( result ); | 99 | resolve( result ); |
96 | - }) | 100 | + }) |
101 | + .catch( ( err ) => { | ||
102 | + throw new Error( err ); | ||
103 | + }); | ||
97 | }) | 104 | }) |
98 | } | 105 | } |
99 | 106 | ||
... | @@ -109,7 +116,10 @@ search.google = ( keywordText ) => { | ... | @@ -109,7 +116,10 @@ search.google = ( keywordText ) => { |
109 | .then( ( html ) => { | 116 | .then( ( html ) => { |
110 | result = getHtmlMain( googleMain, keywordText, html, googleURL, google ); | 117 | result = getHtmlMain( googleMain, keywordText, html, googleURL, google ); |
111 | resolve( result ); | 118 | resolve( result ); |
112 | - }) | 119 | + }) |
120 | + .catch( ( err ) => { | ||
121 | + throw new Error( err ); | ||
122 | + }); | ||
113 | }) | 123 | }) |
114 | } | 124 | } |
115 | 125 | ... | ... |
-
Please register or login to post a comment