Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for redirect links. #1

Open
notnotrachit opened this issue Feb 11, 2021 · 4 comments
Open

Add support for redirect links. #1

notnotrachit opened this issue Feb 11, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@notnotrachit
Copy link

Not working for redirect links. eg. https://discordgift.site/Tr35II4R39SsCjrT

@PGgamer2 PGgamer2 added the enhancement New feature or request label Feb 11, 2021
@PGgamer2 PGgamer2 changed the title Not working for redirect links. Add support for redirect links. Feb 11, 2021
@PGgamer2
Copy link
Owner

PGgamer2 commented Feb 11, 2021

Initially I wanted to use fetch because there's an option for link redirection

fetch("https://discordgift.site/Tr35II4R39SsCjrT", { method: 'GET', redirect: 'follow'})
	.then(response => {
		console.log(response.url);
	})
	.catch(function(err) {
		console.info(err);
	});

However it doesn't work because of the CORS policy.
The only solution would be to use a server-side method, and GitHub Pages doesn't support it.

@PGgamer2 PGgamer2 reopened this Feb 12, 2021
@JoshAtticus
Copy link

If you had the code for a server, I can host one for you. I've got an always-on computer dedicated to hosting servers.

@PGgamer2
Copy link
Owner

Well, I just checked what https://discordgift.site/Tr35II4R39SsCjrT really does.
By GETting this URL you don't obtain a 30x redirection response code, but an HTML page that instantly redirects you to YouTube using JavaScript and, at the same time, an HTML meta tag called http-equiv. This means that fetch, XMLHttpRequest, request, etc. can't detect that this link has any type of redirection.
To detect if a URL like this one redirects to a rickroll we would need to do one of the following:

  • Check if the HTML document contains the YouTube URL. This could easily fail if the link is encrypted and then decrypted on runtime.
  • Run the JS code and wait for the redirection. This is potentially dangerous if a user inputs a URL with malicious JS code.

@JoshAtticus
Copy link

Run the JS code and wait for the redirection. This is potentially dangerous if a user inputs a URL with malicious JS code.

The computer runs everything in a sandbox on top of linux, so I don't think that security is an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants