From e507335923c29be88ba87bf5317e49078aa23635 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 21 Sep 2021 22:10:09 +0200 Subject: [PATCH] Leading and trailing whitespaces are now trimmed from TheGamesDB scraper searches. --- es-app/src/scrapers/GamesDBJSONScraper.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/es-app/src/scrapers/GamesDBJSONScraper.cpp b/es-app/src/scrapers/GamesDBJSONScraper.cpp index b35f1a2c3..4c015d38c 100644 --- a/es-app/src/scrapers/GamesDBJSONScraper.cpp +++ b/es-app/src/scrapers/GamesDBJSONScraper.cpp @@ -158,6 +158,18 @@ void thegamesdb_generate_json_scraper_requests( 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(c)); + })); + cleanName.erase( + std::find_if(cleanName.rbegin(), cleanName.rend(), + [](char c) { return !std::isspace(static_cast(c)); }) + .base(), + cleanName.end()); + path += "/Games/ByGameName?" + apiKey + "&fields=players,publishers,genres,overview,last_updated,rating," "platform,coop,youtube,os,processor,ram,hdd,video,sound,alternates&name=" +