Skip to content
Snippets Groups Projects
Commit 5bd22f5a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

urls don't contain double / characters

parent cd38d400
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!464Resolve "upgrade 3rd party libraries"
......@@ -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) {
......
......@@ -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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment