-
Notifications
You must be signed in to change notification settings - Fork 490
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
Allows named short-links #68
base: main
Are you sure you want to change the base?
Conversation
There is the possibility of overwriting short links by someone who creates the same named link. I don't think your current code has any safeguards against that and I cannot seem to think of any easy safe guards that would retain the simple spirit of this project. Nevertheless, thank you for your input and do let me know if you have any more ideas. One more question, how did you know about this project? |
My only idea is to have it check that the author of the issue is the same as a predefined author, which would be easy given that the /issues endpoint returns usernames. Then again, it may cause very minor complications to simplicity, even being just one extra line. However, we could just allow the user to write var username = "....";
var repository = "...."; and then easily build the endpoint URL. Would allow both checking for users and keeping the simplicity of this project.
I actually don't remember, I found out about it a while ago, pretty sure it was from this https://github.com/n1c00o/bruh.tk/. |
It was apparently much cleaner than that. Checking https://docs.github.com/en/rest/reference/issues I noticed that the issues endpoint also tells you who the repository owner is. We just had to check whether the owner of the issue is the owner of the repo (or if the user is happy allowing others to add named endpoints). Feel free to use or disregard my ideas 😄, but just thought it could be interesting |
Hmm ok so you are suggesting that in a sense we create a private url shortener that only one github user can create short links for? |
In essence, yes. At least, private but can be toggled (as per my last commit), so if users want it to be public + anyone can use then they can. Figuring out which named link to use if there are multiple links with the same name is a problem, but I'm sure there's an easy way to it given some thinking |
@starsFlower I love this addition! I have a question though, what's the format for enabling/using the word url? Is it
Also some suggestions with the duplicates, maybe make it search for issues and show a bunch of matches on the html or issues page, if there's more than 2 matches. By doing that you could use the provided |
Hey @fluteds, it's the URL in the title (just like the standard ones) and the name in the body. I love your idea on how to handle duplicates...it would be very easy to implement as well — just collect any that match the keyword and display a list of those Could definitely do it |
@starsFlower Hello! I tried out your PR and the link doesn't redirect automatically. The page gets stuck on the I'm using a CNAME e.g. |
@fluteds Does the console give any error? |
@starsFlower Nothing other than |
This PR allows "named short links".
If a number is provided as the specifier, the code will run as before. If a word is provided, the page will instead collect the issues of the DB repository, find the issue whose content is the same as the word, and then redirect as expected.
If no repository is found, it will redirect as before.
Edit: Forgot to add, this also allows querying the URL. By placing a
?
after the URL, it will not redirect and instead, it will show the URL that this short link redirects to in a similar manner to bit.ly.