Skip to content

Commit

Permalink
Update: bing urls now working!
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinldev committed Jun 15, 2024
1 parent 00772ea commit 10981c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function getBing(q, n): Promise<Results[]> {

$("li.b_algo").each((div, productHTMLElement) => {
const title: string = $(productHTMLElement).find("li.b_algo h2 a").text() as string;
const displayUrl: string = $(productHTMLElement).find("div.b_attribution").text() as string;
let displayUrl: string = $(productHTMLElement).find("li.b_algo h2 a").attr('href') as string;
const desc: string = $(productHTMLElement).find("p.b_lineclamp4.b_algoSlug").text() as string;

const urlnospace = displayUrl.replace(/ /g, '');
Expand All @@ -95,6 +95,11 @@ async function getBing(q, n): Promise<Results[]> {
url = 'https://' + url;
}

if (url.includes('...') || displayUrl.includes('...')) {
url = url.substring(0, url.indexOf('...'));
displayUrl = displayUrl.substring(0, displayUrl.indexOf('...'));
}

if (!url.endsWith('/')) {
url += '/';
}
Expand Down

0 comments on commit 10981c8

Please sign in to comment.