Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nbitzz committed Jan 27, 2023
1 parent 8f2f6d2 commit 1ba3b27
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ TOKEN=KILL-YOURSELF.NOW
- [X] 1.2.0 add file parameters section + custom ids
- [X] 1.2.1 add file counter to main page
- [X] 1.2.2 clean up this shitty code
- [ ] 1.2.3 add id locks, allowing you to set a key for a file that allows you to overwrite the file in the future
- [ ] 1.2.4 prevent cloning of local/private ip addresses
- [X] 1.2.3 bugfixes
- [ ] 1.2.4 add id locks, allowing you to set a key for a file that allows you to overwrite the file in the future
- [ ] 1.2.5 prevent cloning of local/private ip addresses
- [ ] 1.3.0 add simple moderation tools
- [ ] 2.0.0 rewrite using theUnfunny's code as a base/rewrite using monofile-core

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monofile",
"version": "1.2.2",
"version": "1.2.3",
"description": "Discord-based file sharing",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ app.post("/clone",(req,res) => {
res.send("[err] invalid url")
}
axios.get(j.url,{responseType:"arraybuffer"}).then((data:AxiosResponse) => {
files.uploadFile({name:req.body.split("/")[req.body.split("/").length-1] || "generic",mime:data.headers["content-type"],uploadId:j.uploadId},Buffer.from(data.data))
files.uploadFile({name:j.url.split("/")[req.body.split("/").length-1] || "generic",mime:data.headers["content-type"],uploadId:j.uploadId},Buffer.from(data.data))
.then((uID) => res.send(uID))
.catch((stat) => {res.status(stat.status);res.send(`[err] ${stat.message}`)})
}).catch((err) => {
Expand All @@ -128,7 +128,17 @@ app.get("/download/:fileId",(req,res) => {

fs.readFile(__dirname+"/../pages/download.html",(err,buf) => {
if (err) {res.sendStatus(500);console.log(err);return}
res.send(buf.toString().replace(/\$FileId/g,req.params.fileId).replace(/\$Version/g,pkg.version).replace(/\$FileName/g,file.filename))
res.send(
buf.toString()
.replace(/\$FileId/g,req.params.fileId)
.replace(/\$Version/g,pkg.version)
.replace(/\$FileName/g,
file.filename
.replace(/\&/g,"&")
.replace(/\</g,"&lt;")
.replace(/\>/g,"&gt;")
)
)
})
} else {
ThrowError(res,404,"File not found.")
Expand Down

0 comments on commit 1ba3b27

Please sign in to comment.