From 0ae87edb6b1a62ce232372d43302aa226593745e Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 21 Oct 2012 15:17:50 +0100 Subject: [PATCH] Serving new client code --- server/http-handler.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/http-handler.js b/server/http-handler.js index 83d7d35..950f1e5 100755 --- a/server/http-handler.js +++ b/server/http-handler.js @@ -13,11 +13,20 @@ module.exports.HttpHandler = HttpHandler; HttpHandler.prototype.serve = function (request, response) { + // The incoming requests root directory (ie. /kiwiclient/) + // TODO: check the config for this setting + var root_path = '/client', + root_path_regex = root_path.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); + + // Any asset request to head into the asset dir + request.url = request.url.replace(root_path + '/assets/', '/assets/'); + // Any requests for /client to load the index file - if (request.url.match(/^\/client/)) { + if (request.url.match(new RegExp('^' + root_path_regex, 'i'))) { request.url = '/'; } + this.file_server.serve(request, response, function (err) { if (err) { response.writeHead(err.status, err.headers); -- 2.25.1