More robust ID parser

pull/57/head
MillenniumEarl 2020-11-30 13:22:35 +01:00
parent a5e036d6fd
commit 14c4cce88e
1 changed files with 4 additions and 5 deletions

View File

@ -375,13 +375,12 @@ function isMod(prefix) {
*/
function extractIDFromURL(url) {
// URL are in the format https://f95zone.to/threads/GAMENAME-VERSION-DEVELOPER.ID/
const splitted = url.split(".");
// We took the last part (clean it)
const value = splitted.pop().replace("/", "").trim();
// or https://f95zone.to/threads/ID/
const match = url.match(/(\.)?([0-9]+)(?!-)/);
if(!match) return -1;
// Parse and return number
return parseInt(value, 10);
return parseInt(match[0], 10);
}
/**