*/\r
\r
var index_src = fs.readFileSync(__dirname + '/src/index.html.tmpl', FILE_ENCODING)\r
- .replace(new RegExp('<%base_path%>', 'g'), config.get().http_base_path || '/kiwi')\r
+ .replace(new RegExp('<%base_path%>', 'g'), config.get().http_base_path || '')\r
.replace(new RegExp('<%build_version%>', 'g'), package_json.version);\r
\r
fs.writeFile(__dirname + '/index.html', index_src, { encoding: FILE_ENCODING }, function (err) {\r
}\r
\r
// The base url to the kiwi server\r
- this.set('base_path', options.base_path ? options.base_path : '/kiwi');\r
+ this.set('base_path', options.base_path ? options.base_path : '');\r
\r
// Path for the settings.json file\r
this.set('settings_path', options.settings_path ?\r
HttpHandler.prototype.serve = function (request, response) {
// The incoming requests base path (ie. /kiwiclient)
- var base_path = global.config.http_base_path || '/kiwi',
- base_path_regex;
+ var base_path = global.config.http_base_path || '',
+ whitelisted_folders = ['assets', 'src'];
- // Trim of any trailing slashes
+ // Trim off any trailing slashes
if (base_path.substr(base_path.length - 1) === '/') {
base_path = base_path.substr(0, base_path.length - 1);
}
- // Build the regex to match the base_path
- base_path_regex = base_path.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
-
- // Any asset request to head into the asset dir
- request.url = request.url.replace(base_path + '/assets/', '/assets/');
-
- // Any src request to head into the src dir
- request.url = request.url.replace(base_path + '/src/', '/src/');
+ // Map any whitelisted folders to the local directories
+ whitelisted_folders.forEach(function(folder) {
+ request.url = request.url.replace(base_path + '/' + folder + '/', '/' + folder + '/');
+ });
- // Any requests for /client to load the index file
- if (request.url.match(new RegExp('^' + base_path_regex + '([/$]|$)', 'i'))) {
+ // Any requests for /base_path/* to load the index file
+ console.log(request.url, base_path);
+ if (request.url.toLowerCase().indexOf(base_path.toLowerCase()) === 0) {
request.url = '/index.html';
}