From 04d1b864c34b45710acd70822f257ee4e081b04a Mon Sep 17 00:00:00 2001 From: "samuele.berlusconi" Date: Thu, 22 Oct 2020 13:48:26 +0200 Subject: [PATCH] Clean strings from invalid Win/UNIX'path chars --- app/scripts/game-scraper.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/scripts/game-scraper.js b/app/scripts/game-scraper.js index 0c11be6..0fea13c 100644 --- a/app/scripts/game-scraper.js +++ b/app/scripts/game-scraper.js @@ -55,7 +55,7 @@ module.exports.getGameInfo = async function (browser, url) { info.tags = await tags; info.f95url = await redirectUrl; info.overview = overview; - info.version = info.isMod ? parsedInfos.MOD_VERSION : parsedInfos.VERSION; + info.version = info.isMod ? cleanFSString(parsedInfos.MOD_VERSION) : cleanFSString(parsedInfos.VERSION); info.lastUpdate = info.isMod ? parsedInfos.UPDATED : parsedInfos.THREAD_UPDATED; @@ -104,6 +104,16 @@ module.exports.getGameVersionFromTitle = async function (browser, info) { }; //#region Private methods +/** + * Clean a string from invalid File System chars. + * @param {String} s + * @returns {String} + */ +function cleanFSString(s) { + const rx = /[/\\?%*:|"<>]/g; + return s.replace(rx, ""); +} + /** * @private * Get the game description from its web page.