Helioviewer-Project/api

Update LinkShortener.php to use a hash instead of random numbers

Closed this issue · 4 comments

By using a hash instead of random numbers, the same long url will return the same short url.

This is the function that should be updated to accept the longUrl as an input, and return a hash.

protected static function GenerateShortString(): string {

Hey @dgarciabriseno , I can take this issue.
just to confirm the changes

  1. make the function GenerateShortString() accept longurl as args and then return a random hash
  2. make changes to the public static function Create(string $longUrl): string as well.

@prabhjotsingh18, thanks for your interest, the issue is still open and you can work on it.

For the changes

  1. The hash returned shouldn't be random, it should return a hash of $longUrl
  2. Yes, all calls to GenerateShortString need to be updated.

Thanks for clearing my doubts @dgarciabriseno , will send out a PR soon.

Thanks!