Some updates!

This commit is contained in:
QuiteAFancyEmerald 2021-11-29 22:02:24 -08:00
parent 47a843bbb8
commit df4ce2ae68
No known key found for this signature in database
GPG key ID: 14E10C9F7DC07318
1412 changed files with 188615 additions and 149532 deletions

View file

@ -1,21 +0,0 @@
function createGateway(ctx) {
return function gateway(clientRequest, clientResponse) {
const chunks = [];
clientRequest.on('data', chunk =>
chunks.push(chunk)
).on('end', () => {
const body = chunks.length ? Buffer.concat(chunks) : '';
const query = clientRequest.method == 'POST' ? new URLSearchParams((body || '').toString()) : new URLSearchParams((clientRequest.url.split('?')[1] || ''));
if (!query.has('url')) return clientResponse.end();
const url = query.get('url');
if (/https?:\/\/([a-zA-Z0-9\-\_])|([a-zA-Z0-9\-\_])\.([a-zA-Z])/.test(url)) {
clientResponse.writeHead(301, { Location: ctx.url.wrap(/https?:\/\//.test(url) ? url : 'http://' + url) });
clientResponse.end();
} else {
clientResponse.writeHead(301, { Location: ctx.url.wrap('https://www.google.com/search?q=' + url) });
clientResponse.end();
};
});
};
};
module.exports = createGateway;