diff --git a/src/Server.ts b/src/Server.ts index 9996f07..f79437d 100644 --- a/src/Server.ts +++ b/src/Server.ts @@ -20,10 +20,25 @@ console.log("[Database] connected"); await this.registerRoutes(path.join(__dirname, "routes/")); + this.app.use("/icons/", avatarsRoute); 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.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(); } diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts index 8001c60..119e990 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts @@ -4,8 +4,9 @@ import "missing-native-js-functions"; 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 - return join(process.env.STORAGE_LOCATION || "../", relative("/", path)); + return join(process.env.STORAGE_LOCATION || "../", path); } export class FileStorage implements Storage { @@ -22,7 +23,6 @@ } async delete(path: string) { - path = join(process.env.STORAGE_LOCATION || "", path); - fs.unlinkSync(path); + fs.unlinkSync(getPath(path)); } }