mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Added mime filter
This commit is contained in:
1
package-lock.json
generated
1
package-lock.json
generated
@ -14,6 +14,7 @@
|
|||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"ipaddr.js": "^2.0.1",
|
"ipaddr.js": "^2.0.1",
|
||||||
"jimp": "^0.22.7",
|
"jimp": "^0.22.7",
|
||||||
|
"mime-types": "^2.1.35",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"node-rest-client": "^3.1.1",
|
"node-rest-client": "^3.1.1",
|
||||||
"open": "^8.4.0",
|
"open": "^8.4.0",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"ipaddr.js": "^2.0.1",
|
"ipaddr.js": "^2.0.1",
|
||||||
"jimp": "^0.22.7",
|
"jimp": "^0.22.7",
|
||||||
|
"mime-types": "^2.1.35",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"node-rest-client": "^3.1.1",
|
"node-rest-client": "^3.1.1",
|
||||||
"open": "^8.4.0",
|
"open": "^8.4.0",
|
||||||
|
15
server.js
15
server.js
@ -15,6 +15,7 @@ const PNGtext = require('png-chunk-text');
|
|||||||
const jimp = require('jimp');
|
const jimp = require('jimp');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const sanitize = require('sanitize-filename');
|
const sanitize = require('sanitize-filename');
|
||||||
|
const mime = require('mime-types');
|
||||||
|
|
||||||
const cookieParser = require('cookie-parser');
|
const cookieParser = require('cookie-parser');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
@ -987,13 +988,17 @@ function getCharacterFile(directories, response, i) { //old need del
|
|||||||
response.send(JSON.stringify(characters));
|
response.send(JSON.stringify(characters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getImages(path) {
|
|
||||||
return fs.readdirSync(path).sort(Intl.Collator().compare);
|
|
||||||
|
|
||||||
/* return fs.readdirSync(path).sort(function (a, b) {
|
function getImages(path) {
|
||||||
return new Date(fs.statSync(path + '/' + a).mtime) - new Date(fs.statSync(path + '/' + b).mtime);
|
return fs
|
||||||
}).reverse(); */
|
.readdirSync(path)
|
||||||
|
.filter(file => {
|
||||||
|
const type = mime.lookup(file);
|
||||||
|
return type && type.startsWith('image/');
|
||||||
|
})
|
||||||
|
.sort(Intl.Collator().compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKoboldSettingFiles(path) {
|
function getKoboldSettingFiles(path) {
|
||||||
return fs.readdirSync(path).sort(function (a, b) {
|
return fs.readdirSync(path).sort(function (a, b) {
|
||||||
return new Date(fs.statSync(path + '/' + a).mtime) - new Date(fs.statSync(path + '/' + b).mtime);
|
return new Date(fs.statSync(path + '/' + a).mtime) - new Date(fs.statSync(path + '/' + b).mtime);
|
||||||
|
Reference in New Issue
Block a user