mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-04-21 08:11:53 +02:00
use url instead
This commit is contained in:
parent
bb666b5e1a
commit
4e88147058
1 changed files with 10 additions and 2 deletions
|
@ -31,7 +31,7 @@ let rawdata = fs.readFileSync(usersFolderPath + 'users.json');
|
||||||
let users = JSON.parse(rawdata);
|
let users = JSON.parse(rawdata);
|
||||||
let userDict = {}
|
let userDict = {}
|
||||||
for (var i in users) {
|
for (var i in users) {
|
||||||
userDict[users[i].title.replaceAll("/", "-")] = true;
|
userDict[parseDirname(users[i])] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = fs.readdirSync(usersFolderPath);
|
const files = fs.readdirSync(usersFolderPath);
|
||||||
|
@ -54,6 +54,14 @@ for (file in files) {
|
||||||
|
|
||||||
var cache = {};
|
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) {
|
async function convert(text, from, to) {
|
||||||
var options = {
|
var options = {
|
||||||
from: from,
|
from: from,
|
||||||
|
@ -121,7 +129,7 @@ puppeteer
|
||||||
layoutBackgroundHeaderSpace: false\n\
|
layoutBackgroundHeaderSpace: false\n\
|
||||||
\r---\n";
|
\r---\n";
|
||||||
|
|
||||||
var dir = usersFolderPath + users[i].url.split("//").at(1).replaceAll('/', '');
|
var dir = usersFolderPath + parseDirname(users[i]);
|
||||||
|
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
fs.mkdirSync(dir);
|
fs.mkdirSync(dir);
|
||||||
|
|
Loading…
Add table
Reference in a new issue