b2g-scripts
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "b2g-scripts", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"author": "James Lal <jlal@mozilla.com>", | ||
@@ -5,0 +5,0 @@ "description": "B2G/Gaia Helper Scripts", |
@@ -19,2 +19,7 @@ var Server = require('../lib/script')({ | ||
forward: { | ||
alias: 'f', | ||
desc: 'Forward all paths without extension to index.html' | ||
}, | ||
port: { | ||
@@ -77,15 +82,20 @@ alias: 'p', | ||
var HAS_EXTENSION = /\.[a-zA-Z9-9]+(\?(.*))?$/ | ||
var SHARED = /^\/?shared/ | ||
require('http').createServer(function (request, response) { | ||
request.addListener('end', function () { | ||
var host = request.headers.host, | ||
app = host.split('.')[0]; | ||
var host = request.headers.host; | ||
var app = host.split('.')[0]; | ||
if(apps[app]) { | ||
if(apps[app] && !SHARED.test(request.url)) { | ||
var url; | ||
if(argv.forward && !HAS_EXTENSION.test(request.url)) { | ||
request.url = fsPath.join('/' + apps[app], app, 'index.html'); | ||
} else { | ||
request.url = fsPath.join('/' + apps[app], app, request.url); | ||
file.serve( | ||
request, response | ||
); | ||
} else { | ||
file.serve(request, response); | ||
} | ||
} | ||
file.serve(request, response); | ||
}); | ||
@@ -92,0 +102,0 @@ }).listen(port); |
13335
368