From 2f229fb449bfaca508651129dfe16d703aa6f6d9 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:35:44 +0200 Subject: [PATCH] typescript(translucid): fixed forbbiden sendFile Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 4 +++- typescript/translucid/Translucid.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index a725411..164c70a 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -1,7 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const express = require('express'); +const path = require('path'); const read_1 = require("./read"); +const dir = path.dirname(require.main.filename); function containsAny(array, keys) { for (let i = 0; i < keys.length; i++) { if (array.indexOf(keys[i]) != -1) @@ -53,7 +55,7 @@ class Translucid { else res.sendFile(prev); }); - decorated[0]((!sendFiles) ? readResults : `${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles) ? readResults : `${dir}/${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 667d9c9..81a9baf 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -1,6 +1,9 @@ const express = require('express'); +const path = require('path'); import {read} from "./read"; +const dir = path.dirname(require.main.filename); + interface Middleware{ name:string; keys:Array; @@ -61,7 +64,7 @@ class Translucid { res.sendFile(prev); }); - decorated[0]((!sendFiles)?readResults:`${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles)?readResults:`${dir}/${filepath}`); }); } }