forked from cory/tildefriends
Move / redirect handling to C
This commit is contained in:
29
core/core.js
29
core/core.js
@ -1425,34 +1425,7 @@ loadSettings()
|
||||
httpd.all('/app/socket', app.socket);
|
||||
httpd.all('', function default_http_handler(request, response) {
|
||||
let match;
|
||||
if (request.uri === '/' || request.uri === '') {
|
||||
let host = request.headers['x-forwarded-host'] ?? request.headers.host;
|
||||
try {
|
||||
for (let line of (gGlobalSettings.index_map || '').split('\n')) {
|
||||
let parts = line.split('=');
|
||||
if (parts.length == 2 && host.match(new RegExp(parts[0], 'i'))) {
|
||||
response.writeHead(303, {
|
||||
Location:
|
||||
(request.client.tls ? 'https://' : 'http://') +
|
||||
host +
|
||||
parts[1],
|
||||
'Content-Length': '0',
|
||||
});
|
||||
return response.end();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
response.writeHead(303, {
|
||||
Location:
|
||||
(request.client.tls ? 'https://' : 'http://') +
|
||||
host +
|
||||
gGlobalSettings.index,
|
||||
'Content-Length': '0',
|
||||
});
|
||||
return response.end();
|
||||
} else if ((match = /^(\/~[^\/]+\/[^\/]+)(\/?.*)$/.exec(request.uri))) {
|
||||
if ((match = /^(\/~[^\/]+\/[^\/]+)(\/?.*)$/.exec(request.uri))) {
|
||||
return blobHandler(request, response, match[1], match[2]);
|
||||
} else if (
|
||||
(match = /^\/([&\%][^\.]{44}(?:\.\w+)?)(\/?.*)/.exec(request.uri))
|
||||
|
Reference in New Issue
Block a user