Leading and trailing whitespaces are now trimmed from TheGamesDB scraper searches.

This commit is contained in:
Leon Styhre 2021-09-21 22:10:09 +02:00
parent 8f82809a89
commit e507335923

View file

@ -158,6 +158,18 @@ void thegamesdb_generate_json_scraper_requests(
cleanName = params.game->getCleanName(); cleanName = params.game->getCleanName();
} }
} }
// Trim leading and trailing whitespaces.
cleanName.erase(cleanName.begin(),
std::find_if(cleanName.begin(), cleanName.end(), [](char c) {
return !std::isspace(static_cast<unsigned char>(c));
}));
cleanName.erase(
std::find_if(cleanName.rbegin(), cleanName.rend(),
[](char c) { return !std::isspace(static_cast<unsigned char>(c)); })
.base(),
cleanName.end());
path += "/Games/ByGameName?" + apiKey + path += "/Games/ByGameName?" + apiKey +
"&fields=players,publishers,genres,overview,last_updated,rating," "&fields=players,publishers,genres,overview,last_updated,rating,"
"platform,coop,youtube,os,processor,ram,hdd,video,sound,alternates&name=" + "platform,coop,youtube,os,processor,ram,hdd,video,sound,alternates&name=" +