ash-jc-allen / short-url

A Laravel package for creating shortened URLs for your web apps.
MIT License
1.25k stars 158 forks source link

redirect to url instead of throwing 404 #220

Closed Saifallak closed 6 months ago

Saifallak commented 10 months ago

what do you think of that feature? are you open for PR to do that?

ash-jc-allen commented 10 months ago

Hey @Saifallak! Would this be for if a short URL with the given key didn't exist? Or would it be for if the destination URL (that we're redirecting to) doesn't exist? 🙂

Saifallak commented 10 months ago

if a short URL with the given key didn't exist


i don't have any control over destinations

ash-jc-allen commented 10 months ago

I think I'd be open to something like that, yeah! 😄

I don't know if you already have any ideas (which I'm open to), but I'd probably be leaning towards something like letting the developer define the custom behaviour in a service provider and doing something like:

ShortURL::handleMissingUsing(function () {
    // Logic goes here that is run when we visit a short URL that doesn't exist.
});

Feel free to suggest anything else though that you might think would be useful 🙂