diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-07 15:44:56 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-07 15:44:56 +0200 |
commit | 3bc8a96afdeb337e6d6972e0c989b11bcdbbe70e (patch) | |
tree | 987d3600785aaa307310bcb877132e9847189001 | |
parent | :sparkles: icons + banners route (diff) | |
download | server-3bc8a96afdeb337e6d6972e0c989b11bcdbbe70e.tar.xz |
:bug: fix path
-rw-r--r-- | src/Server.ts | 15 | ||||
-rw-r--r-- | src/util/FileStorage.ts | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/Server.ts b/src/Server.ts index 9996f07a..f79437d5 100644 --- a/src/Server.ts +++ b/src/Server.ts @@ -20,10 +20,25 @@ export class CDNServer extends Server { 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 8001c608..119e990f 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts @@ -4,8 +4,9 @@ import { join, relative } from "path"; 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 @@ export class FileStorage implements Storage { } async delete(path: string) { - path = join(process.env.STORAGE_LOCATION || "", path); - fs.unlinkSync(path); + fs.unlinkSync(getPath(path)); } } |