diff --git a/index.js b/index.js index 5753232..a23f145 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,12 @@ const btb = require("blob-to-buffer"); class SecureFile { constructor(server, username, private_key) { this.Server = server; + if (this.Server.endsWith("/")) { + this.Server += "api"; + } + else { + this.Server += "/api"; + } this.Username = username; this.PrivateKey = private_key; } diff --git a/index.ts b/index.ts index f9cd3e7..d98a28e 100644 --- a/index.ts +++ b/index.ts @@ -23,6 +23,11 @@ export default class SecureFile { private PrivateKey: string; constructor(server: string, username: string, private_key: string) { this.Server = server; + if (this.Server.endsWith("/")) { + this.Server += "api"; + } else { + this.Server += "/api"; + } this.Username = username; this.PrivateKey = private_key; } diff --git a/package.json b/package.json index 769359e..d315102 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "secure-file-wrapper", - "version": "1.0.4", + "version": "1.0.5", "main": "index.js", "author": "Fabian Stamm ", "license": "MIT", diff --git a/test.js b/test.js index 2d925a0..f1ce86d 100644 --- a/test.js +++ b/test.js @@ -20,7 +20,7 @@ module.exports = { setUp: function (finished) { let pk = fs_1.readFileSync("./private.pem"); private_key = pk.toString("utf8"); - sf = new index_1.default("http://localhost:3005/api", "test", private_key); + sf = new index_1.default("http://localhost:3005", "test", private_key); finished(); }, create: async function (test) { diff --git a/test.ts b/test.ts index 76362d1..8899245 100644 --- a/test.ts +++ b/test.ts @@ -39,7 +39,7 @@ module.exports = { setUp: function (finished) { let pk = readFileSync("./private.pem"); private_key = pk.toString("utf8"); - sf = new SecureFile("http://localhost:3005/api", "test", private_key); + sf = new SecureFile("http://localhost:3005", "test", private_key); finished(); }, create: async function (test: TestType) {