mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-13 12:00:02 -04:00
Minor Change (oops)
This commit is contained in:
parent
af2ca7e034
commit
6bd7e10c4d
31 changed files with 34771 additions and 1 deletions
21
src/Corrosion/lib/server/gateway.js
Normal file
21
src/Corrosion/lib/server/gateway.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue