🐛 fix path

This commit is contained in:
Flam3rboy 2021-08-07 15:44:56 +02:00
parent ede8ed4b71
commit 3bc8a96afd
2 changed files with 18 additions and 3 deletions

View File

@ -20,10 +20,25 @@ export class CDNServer extends Server {
console.log("[Database] connected"); console.log("[Database] connected");
await this.registerRoutes(path.join(__dirname, "routes/")); await this.registerRoutes(path.join(__dirname, "routes/"));
this.app.use("/icons/", avatarsRoute); this.app.use("/icons/", avatarsRoute);
this.log("info", "[Server] Route /icons registered"); this.log("info", "[Server] Route /icons registered");
this.app.use("/emojis/", avatarsRoute);
this.log("info", "[Server] Route /emojis registered");
this.app.use("/banners/", avatarsRoute); this.app.use("/banners/", avatarsRoute);
this.log("info", "[Server] Route /banners registered"); this.log("info", "[Server] Route /banners registered");
this.app.use("/banners/", avatarsRoute);
this.log("info", "[Server] Route /banners registered");
this.app.use("/discover-splashes/", avatarsRoute);
this.log("info", "[Server] Route /discover-splashes registered");
this.app.use("/team-icons/", avatarsRoute);
this.log("info", "[Server] Route /team-icons registered");
return super.start(); return super.start();
} }

View File

@ -4,8 +4,9 @@ import { join, relative } from "path";
import "missing-native-js-functions"; import "missing-native-js-functions";
function getPath(path: string) { function getPath(path: string) {
if (path.indexOf("\0") !== -1 || !/^[a-z0-9]+$/.test(path)) throw new Error("invalid path");
// STORAGE_LOCATION has a default value in start.ts // STORAGE_LOCATION has a default value in start.ts
return join(process.env.STORAGE_LOCATION || "../", relative("/", path)); return join(process.env.STORAGE_LOCATION || "../", path);
} }
export class FileStorage implements Storage { export class FileStorage implements Storage {
@ -22,7 +23,6 @@ export class FileStorage implements Storage {
} }
async delete(path: string) { async delete(path: string) {
path = join(process.env.STORAGE_LOCATION || "", path); fs.unlinkSync(getPath(path));
fs.unlinkSync(path);
} }
} }