Compare commits
No commits in common. "35e0b694428057ed06f1576c8e76dc91a655c5ab" and "a0abfb3a62aa6aa56057ece2992d797d3287692d" have entirely different histories.
35e0b69442
...
a0abfb3a62
@ -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 firstName = cleanName.split(/\s+/)[0];
|
|
||||||
const namesToTry = cleanName === firstName ? [cleanName] : [cleanName, firstName];
|
|
||||||
for (const tryName of namesToTry) {
|
|
||||||
const wikiDirect = await fetchJSON(
|
const wikiDirect = await fetchJSON(
|
||||||
"https://en.wikipedia.org/api/rest_v1/page/summary/" + encodeURIComponent(tryName),
|
"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()),
|
||||||
{ timeout: 5000 }
|
{ timeout: 5000 }
|
||||||
);
|
);
|
||||||
if (wikiDirect && wikiDirect.type === "disambiguation") continue; // skip disambiguation pages
|
if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30) {
|
||||||
if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30 && isRelevant(wikiDirect.title, wikiDirect.extract)) {
|
if (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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
server.js
13
server.js
@ -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 firstName = cleanName.split(/\s+/)[0];
|
|
||||||
const namesToTry = cleanName === firstName ? [cleanName] : [cleanName, firstName];
|
|
||||||
for (const tryName of namesToTry) {
|
|
||||||
const wikiDirect = await fetchJSON(
|
const wikiDirect = await fetchJSON(
|
||||||
"https://en.wikipedia.org/api/rest_v1/page/summary/" + encodeURIComponent(tryName),
|
"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()),
|
||||||
{ timeout: 5000 }
|
{ timeout: 5000 }
|
||||||
);
|
);
|
||||||
if (wikiDirect && wikiDirect.type === "disambiguation") continue; // skip disambiguation pages
|
if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30) {
|
||||||
if (wikiDirect && wikiDirect.extract && wikiDirect.extract.length > 30 && isRelevant(wikiDirect.title, wikiDirect.extract)) {
|
if (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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user