diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 01b15bbea04f35ae7e9b73a9cf86eb5da8760bf3..97d8b5d6e6221c49e35eb63041913e6158313b80 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -370,7 +370,7 @@ ServerConnector.getApiUrl = function (paramObj) { var result = paramObj.url; if (result === undefined) { - result = this.getApiBaseUrl() + "/" + type; + result = this.getApiBaseUrl() + type; } if (params !== "") { result += "?" + params; @@ -614,13 +614,13 @@ ServerConnector.getReferenceGenomeOrganismsUrl = function (queryParams, filterPa ServerConnector.loginUrl = function () { return this.getApiUrl({ - type: "/doLogin" + type: "doLogin" }); }; ServerConnector.logoutUrl = function () { return this.getApiUrl({ - type: "/doLogout" + type: "doLogout" }); }; @@ -892,7 +892,7 @@ ServerConnector.getCreateFileUrl = function () { }; ServerConnector.getFileUrl = function (queryParams) { return this.getApiUrl({ - url: this.getFilesUrl() + "/" + queryParams.id + url: this.getFilesUrl() + queryParams.id }); }; ServerConnector.getUploadFileUrl = function (queryParams) { diff --git a/frontend-js/src/test/js/ServerConnector-mock.js b/frontend-js/src/test/js/ServerConnector-mock.js index fa5f72b1f0b1dbb93d97386291cf4fcf646ec32d..ca183829e0a588a06cb1ad42f32c3767b56cae63 100644 --- a/frontend-js/src/test/js/ServerConnector-mock.js +++ b/frontend-js/src/test/js/ServerConnector-mock.js @@ -10,6 +10,8 @@ var NetworkError = require('../../main/js/NetworkError'); var fs = require('fs'); var request = require('request'); +var chai = require('chai'); +var assert = chai.assert; var ServerConnectorMock = OriginalServerConnector; @@ -19,6 +21,7 @@ function replaceAsterisk(str) { function urlToFileName(url) { var result = url; + assert.equal(-1, url.indexOf("//"), "Invalid url: " + url); var token = OriginalServerConnector.getSessionData().getToken(); if (token !== undefined && token !== "" && url.indexOf("./testFiles/apiCalls") === 0) { if (!result.endsWith("&") && !result.endsWith("_")) { @@ -47,7 +50,10 @@ ServerConnectorMock._sendRequest = function (params) { if (prefix === "GET") { prefix = ""; } else { - prefix = "/" + prefix + "_"; + prefix = prefix + "_"; + if (!url.endsWith("/")) { + prefix = "/" + prefix; + } } var suffix = ""; if (params.form !== undefined) { @@ -92,9 +98,9 @@ ServerConnectorMock.getApiBaseUrl = function () { var originalGetApiUrl = OriginalServerConnector.getApiUrl; ServerConnectorMock.getApiUrl = function (paramObj) { - // replace '?' with '/' + // replace '?' (or '/?') with '/' // the call is done on ServerConnectorObject (so 'this' is set properly) - return originalGetApiUrl.call(this, paramObj).replace(/\?/g, '/'); + return originalGetApiUrl.call(this, paramObj).replace(/\/?\?/g, '/'); }; module.exports = ServerConnectorMock;