Skip to content

Commit

Permalink
use url instead
Browse files Browse the repository at this point in the history
  • Loading branch information
wtchangdm committed Nov 8, 2024
1 parent bb666b5 commit 4e88147
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions processUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4e88147

Please sign in to comment.