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

Allows named short-links #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Allows named short-links #68

wants to merge 2 commits into from

Conversation

raclettes
Copy link

@raclettes raclettes commented Mar 23, 2021

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.

@nelsontky
Copy link
Owner

nelsontky commented Mar 23, 2021

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?

@raclettes
Copy link
Author

raclettes commented Mar 23, 2021

I don't think your currebt cide 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.

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.

One more question, how did you know about 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/.

@raclettes
Copy link
Author

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

@nelsontky
Copy link
Owner

nelsontky commented Mar 24, 2021

I don't think your currebt cide 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.

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.

One more question, how did you know about 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/.

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?

@raclettes
Copy link
Author

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

@fluteds
Copy link

fluteds commented May 10, 2021

@starsFlower I love this addition! I have a question though, what's the format for enabling/using the word url?

Is it

  • Name https://website.xyz
  • Name in the title and URL in the body?

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 GITHUB_ISSUES_LINK and use the github docs to make a script to search for the in:title value.

@raclettes
Copy link
Author

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

@fluteds
Copy link

fluteds commented May 11, 2021

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.

@starsFlower Hello! I tried out your PR and the link doesn't redirect automatically. The page gets stuck on the Links to. I'm not too sure if it's a conflict with the ? You mentioned. Unless I'm doing something wrong!

I'm using a CNAME e.g. url.fluted.xyz/github (The /github should link to my GitHub profile.) Though it might be the url. that causes the problem.

@raclettes
Copy link
Author

@fluteds Does the console give any error?

@fluteds
Copy link

fluteds commented May 11, 2021

@fluteds Does the console give any error?

@starsFlower Nothing other than Failed to load resource: the server responded with a status of 404 ()

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

Successfully merging this pull request may close these issues.

None yet

3 participants