Compare commits

..

No commits in common. "35e0b694428057ed06f1576c8e76dc91a655c5ab" and "a0abfb3a62aa6aa56057ece2992d797d3287692d" have entirely different histories.

2 changed files with 14 additions and 24 deletions

View File

@ -3480,20 +3480,15 @@ const server = http.createServer(async (req, res) => {
return titleMatch && (hasNetContext || titleMatch); return titleMatch && (hasNetContext || titleMatch);
}; };
// Direct title lookup — try full name first, then first word as fallback // Direct title lookup
const cleanName = companyName.replace(/\s+(GmbH|AG|Ltd|Inc|LLC|BV|SA|SAS|Oy|AB)$/i, "").trim(); const wikiDirect = await fetchJSON(
const firstName = cleanName.split(/\s+/)[0]; "https://en.wikipedia.org/api/rest_v1/page/summary/" + encodeURIComponent(companyName.replace(/\s+(GmbH|AG|Ltd|Inc|LLC|BV|SA|SAS|Oy|AB)$/i, "").trim()),
const namesToTry = cleanName === firstName ? [cleanName] : [cleanName, firstName]; { timeout: 5000 }
for (const tryName of namesToTry) { );
const wikiDirect = await fetchJSON( if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30) {
"https://en.wikipedia.org/api/rest_v1/page/summary/" + encodeURIComponent(tryName), if (isRelevant(wikiDirect.title, wikiDirect.extract)) {
{ timeout: 5000 }
);
if (wikiDirect && wikiDirect.type === "disambiguation") continue; // skip disambiguation pages
if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30 && isRelevant(wikiDirect.title, wikiDirect.extract)) {
description = wikiDirect.extract.replace(/\s+/g, " ").trim().slice(0, 300); description = wikiDirect.extract.replace(/\s+/g, " ").trim().slice(0, 300);
wikiUrl = wikiDirect.content_urls && wikiDirect.content_urls.desktop && wikiDirect.content_urls.desktop.page; wikiUrl = wikiDirect.content_urls && wikiDirect.content_urls.desktop && wikiDirect.content_urls.desktop.page;
break;
} }
} }

View File

@ -3480,20 +3480,15 @@ const server = http.createServer(async (req, res) => {
return titleMatch && (hasNetContext || titleMatch); return titleMatch && (hasNetContext || titleMatch);
}; };
// Direct title lookup — try full name first, then first word as fallback // Direct title lookup
const cleanName = companyName.replace(/\s+(GmbH|AG|Ltd|Inc|LLC|BV|SA|SAS|Oy|AB)$/i, "").trim(); const wikiDirect = await fetchJSON(
const firstName = cleanName.split(/\s+/)[0]; "https://en.wikipedia.org/api/rest_v1/page/summary/" + encodeURIComponent(companyName.replace(/\s+(GmbH|AG|Ltd|Inc|LLC|BV|SA|SAS|Oy|AB)$/i, "").trim()),
const namesToTry = cleanName === firstName ? [cleanName] : [cleanName, firstName]; { timeout: 5000 }
for (const tryName of namesToTry) { );
const wikiDirect = await fetchJSON( if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30) {
"https://en.wikipedia.org/api/rest_v1/page/summary/" + encodeURIComponent(tryName), if (isRelevant(wikiDirect.title, wikiDirect.extract)) {
{ timeout: 5000 }
);
if (wikiDirect && wikiDirect.type === "disambiguation") continue; // skip disambiguation pages
if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30 && isRelevant(wikiDirect.title, wikiDirect.extract)) {
description = wikiDirect.extract.replace(/\s+/g, " ").trim().slice(0, 300); description = wikiDirect.extract.replace(/\s+/g, " ").trim().slice(0, 300);
wikiUrl = wikiDirect.content_urls && wikiDirect.content_urls.desktop && wikiDirect.content_urls.desktop.page; wikiUrl = wikiDirect.content_urls && wikiDirect.content_urls.desktop && wikiDirect.content_urls.desktop.page;
break;
} }
} }