Commit 5cbf8f28 authored by Ricco Førgaard's avatar Ricco Førgaard

Fixes yet another issue with config.

parent 8f6eeb58
...@@ -4,4 +4,4 @@ To get up and running: ...@@ -4,4 +4,4 @@ To get up and running:
$ bower install $ bower install
$ open index.html $ open index.html
If your REST server expects a namespace on the URL path (such as `/api/study/list` instead of `/study/list`), add it to the `config/config.js`file. You can specify either a namespace (`/api/`) or a URL (`http://my-host:8080/api`). If your REST server expects a namespace on the URL path (such as `/api/study/list` instead of `/study/list`), add it to the `config/config.js`file. You can specify either a namespace (`/api`) or a URL (`http://my-host:8080/api`).
define(['dojo/_base/declare'], function(declare) { window.config = {
return declare('nesstarconfig.config', null, { baseUrl: ''
}
/* API URL namespace */ \ No newline at end of file
baseUrl: '/api/'
});
});
\ No newline at end of file
define(['dojo/_base/declare', define(['dojo/_base/declare',
'dojo/_base/lang', 'dojo/_base/lang',
'dojo/request', 'dojo/request',
'nesstarconfig/config'], function(declare, lang, request, config) { 'nesstarconfig/config'], function(declare, lang, request) {
return declare('nesstartouch._RestMixin', null, { return declare('nesstartouch._RestMixin', null, {
defaultOptions: { defaultOptions: {
method: 'GET', method: 'GET',
...@@ -40,8 +40,12 @@ define(['dojo/_base/declare', ...@@ -40,8 +40,12 @@ define(['dojo/_base/declare',
}, },
addBaseUrl: function(originalUrl) { addBaseUrl: function(originalUrl) {
if (config) { if (window.config) {
return config.baseUrl + originalUrl; var base = window.config.baseUrl;
if (base.indexOf('/', base.length - 1) !== -1) {
base = base.substring(0, base.length - 1);
}
return base + originalUrl;
} }
return originalUrl; return originalUrl;
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment