http: URL pattern matcher fixes.

This commit is contained in:
2024-11-02 20:10:55 -04:00
parent a09fefab5e
commit 30d108fc35
4 changed files with 35 additions and 25 deletions

View File

@ -918,19 +918,6 @@ async function useAppHandler(
* @returns
*/
async function blobHandler(request, response, blobId, uri) {
if (!uri) {
response.writeHead(303, {
Location:
(request.client.tls ? 'https://' : 'http://') +
(request.headers['x-forwarded-host'] ?? request.headers.host) +
blobId +
'/',
'Content-Length': '0',
});
response.end();
return;
}
let process;
let data;
let match;
@ -1072,13 +1059,15 @@ loadSettings()
httpd.set_http_redirect(settings.http_redirect);
}
httpd.all('/app/socket', app.socket);
httpd.all('', function default_http_handler(request, response) {
httpd.all('/~{word}/{word}/*', function default_http_handler(request, response) {
let match;
if ((match = /^(\/~[^\/]+\/[^\/]+)(\/?.*)$/.exec(request.uri))) {
return blobHandler(request, response, match[1], match[2]);
} else if (
(match = /^\/([&\%][^\.]{44}(?:\.\w+)?)(\/?.*)/.exec(request.uri))
) {
}
});
httpd.all('/&*.sha256/*', function default_http_handler(request, response) {
let match;
if ((match = /^\/([&\%][^\.]{44}(?:\.\w+)?)(\/?.*)/.exec(request.uri))) {
return blobHandler(request, response, match[1], match[2]);
}
});