Clean strings from invalid Win/UNIX'path chars

pull/37/head
samuele.berlusconi 2020-10-22 13:48:26 +02:00
parent 183249e0bf
commit 04d1b864c3
1 changed files with 11 additions and 1 deletions

View File

@ -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.