diff --git a/processUsers.js b/processUsers.js index f2ff12ef..0cb39c0d 100644 --- a/processUsers.js +++ b/processUsers.js @@ -31,7 +31,7 @@ let rawdata = fs.readFileSync(usersFolderPath + 'users.json'); let users = JSON.parse(rawdata); let userDict = {} for (var i in users) { - userDict[users[i].title.replaceAll("/", "-")] = true; + userDict[parseDirname(users[i])] = true; } const files = fs.readdirSync(usersFolderPath); @@ -54,6 +54,14 @@ for (file in files) { var cache = {}; +function parseDirname(user) { + return user.url + .split("//") + .at(1) // take everything after protocol + .replaceAll('/', '-') // and replace every slash with hyphen + .replace(/-$/, ''); // and remove the trailing hyphen if there is one +} + async function convert(text, from, to) { var options = { from: from, @@ -121,7 +129,7 @@ puppeteer layoutBackgroundHeaderSpace: false\n\ \r---\n"; - var dir = usersFolderPath + users[i].url.split("//").at(1).replaceAll('/', ''); + var dir = usersFolderPath + parseDirname(users[i]); if (!fs.existsSync(dir)) { fs.mkdirSync(dir);