mirror of https://github.com/AlphaNecron/Void.git
fix(server): ignore queries and hashes on url
This commit is contained in:
parent
6b011e6dd1
commit
6d8e4946f2
24
package.json
24
package.json
|
@ -18,11 +18,11 @@
|
|||
"seed": "ts-node --compiler-options {\"module\":\"commonjs\"} prisma/seed.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@chakra-ui/react": "^1.6.9",
|
||||
"@emotion/react": "^11",
|
||||
"@chakra-ui/react": "^1.6.10",
|
||||
"@emotion/react": "^11.5.0",
|
||||
"@emotion/styled": "^11",
|
||||
"@iarna/toml": "^2.2.5",
|
||||
"@prisma/client": "^3.2.1",
|
||||
"@prisma/client": "^3.3.0",
|
||||
"@reduxjs/toolkit": "^1.6.2",
|
||||
"argon2": "^0.28.2",
|
||||
"cookie": "^0.4.1",
|
||||
|
@ -32,7 +32,7 @@
|
|||
"framer-motion": "^4",
|
||||
"multer": "^1.4.3",
|
||||
"next": "^11.1.2",
|
||||
"prisma": "^3.2.1",
|
||||
"prisma": "^3.3.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-dropzone": "^11.4.2",
|
||||
|
@ -41,19 +41,19 @@
|
|||
"react-responsive": "8.2.0",
|
||||
"react-syntax-highlighter": "^15.4.4",
|
||||
"url-schemify": "^0.1.0",
|
||||
"yup": "^0.32.9"
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^13.2.0",
|
||||
"@commitlint/cli": "^13.2.1",
|
||||
"@commitlint/config-conventional": "^13.2.0",
|
||||
"@types/node": "^16.10.3",
|
||||
"@types/react": "^17.0.27",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@types/node": "^16.11.3",
|
||||
"@types/react": "^17.0.31",
|
||||
"@typescript-eslint/parser": "^5.1.0",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-next": "11.1.2",
|
||||
"husky": "^7.0.2",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.3.2",
|
||||
"husky": "^7.0.4",
|
||||
"ts-node": "^10.3.1",
|
||||
"typescript": "^4.4.4",
|
||||
"yarn-run-all": "^3.1.1"
|
||||
},
|
||||
"commitlint": {
|
||||
|
|
|
@ -128,5 +128,5 @@
|
|||
- Album / Bulk upload
|
||||
|
||||
### Credits
|
||||
- Most of source code and API from `diced/zipline`
|
||||
- Source code and API from `diced/zipline`
|
||||
- Logo and favicon from `icons8`
|
|
@ -45,9 +45,11 @@ const dev = process.env.NODE_ENV === 'development';
|
|||
if (req.url.startsWith(config.uploader.raw_route)) {
|
||||
const parts = req.url.split('/');
|
||||
if (!parts[2] || parts[2] === '') return;
|
||||
const fileName = parts[2].replace(/[\#\?].*$/ig, '');
|
||||
if (!fileName || fileName === '') return;
|
||||
let data;
|
||||
try {
|
||||
data = await readFile(join(process.cwd(), config.uploader.directory, parts[2]));
|
||||
data = await readFile(join(process.cwd(), config.uploader.directory, fileName));
|
||||
}
|
||||
catch {
|
||||
app.render404(req, res);
|
||||
|
@ -57,13 +59,13 @@ const dev = process.env.NODE_ENV === 'development';
|
|||
} else {
|
||||
let file = await prisma.file.findFirst({
|
||||
where: {
|
||||
fileName: parts[2],
|
||||
fileName,
|
||||
}
|
||||
});
|
||||
if (file) {
|
||||
res.setHeader('Content-Type', file.mimetype);
|
||||
} else {
|
||||
const mimetype = mimetypes[extname(parts[2])] ?? 'application/octet-stream';
|
||||
const mimetype = mimetypes[extname(fileName)] ?? 'application/octet-stream';
|
||||
res.setHeader('Content-Type', mimetype);
|
||||
}
|
||||
res.setHeader('Content-Length', data.byteLength);
|
||||
|
|
Loading…
Reference in New Issue