f0ck-fe-old/test2/lib/lib.js
2021-12-31 07:18:41 +01:00

35 lines
1.1 KiB
JavaScript

var getlink = tmp => {
const tpl = {
user: ({ user, mime, last, eps }) => `user,${user},${mime},${last},${eps}`,
mime: ({ user, mime, last, eps }) => `mime,${mime},${user},${last},${eps}`,
new: ({ user, mime, last, eps }) => `items,${last},${eps}`,
};
let api = "/api/?";
tmp = (tmp.match(/,/)?tmp:`${tmp},`).substr(1).split(",");
const args = {
l: tmp[0].split("/"),
r: tmp[1].split("/")
};
tmp = {
mode: "",
user: "",
mime: "",
last: 0,
post: 0
};
tmp.mode = ( args.l[0].length === 0 )? "new" : args.l[0];
tmp.last = parseInt(args.r[0]) || 0;
tmp.post = parseInt(args.r[1]) || 0;
switch(tmp.mode) {
case "user":
tmp.user = ( args.l[1].length === 0 )? "" : args.l[1];
tmp.mime = ( args.l[2].length === 0 )? "" : args.l[2];
break;
case "mime":
tmp.user = ( args.l[2].length === 0 )? "" : args.l[2];
tmp.mime = ( args.l[1].length === 0 )? "" : args.l[1];
break;
}
return api + [{ user: tmp.user, mime: tmp.mime, last: tmp.last, eps: 3 }].map(tpl[tmp.mode]).join``;
};