Don't include characters that cause problems in search queries

Still match against the full page title when parsing the results page to find the ID, just in case being less specific causes multiple items to be returned
This commit is contained in:
ewin 2025-04-03 08:27:09 -04:00
parent 5775ae0a8e
commit 83aa11c5d0
Signed by: erin
SSH key fingerprint: SHA256:swjoHhREbZPbWe+gyJNi24d4NAxJSyUIm3fpZj4z3wc

View file

@ -22,7 +22,7 @@ const itemLinkRegExp = name => new RegExp(`<a href="/lodestone/playguide/db/item
*/
export async function findItemEDBID (name) {
// execute a search for the item's name
const searchURL = `https://na.finalfantasyxiv.com/lodestone/playguide/db/item/?q=${encodeURIComponent(name)}`;
const searchURL = `https://na.finalfantasyxiv.com/lodestone/playguide/db/item/?q=${encodeURIComponent(name.replace(/\([^)]+\)|&/g, ' '))}`;
const response = await fetch(searchURL);
const body = await response.text();
// find an `<a>` in the HTML response whose text exactly matches the name