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

Ability for multiple domains #15

Open
KnightAR opened this issue Apr 14, 2023 · 3 comments
Open

Ability for multiple domains #15

KnightAR opened this issue Apr 14, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@KnightAR
Copy link

Summary:

Provide ability to build short URLs that has multiple domains/prefixes

Use cases:

I develop a SAS project that we would like to incorporate this package into. However, Since we have multiple domains for different things we'd like to be able to specify which domain to use. For example, we want to send a short link for a specific feature set that is under one domain or subdomain but also want to provide shortlinks for another domain under the same sourecode and configuration setup. The current code base as it stands won't allow me to create these shortlinks easily without some string replacement which I would prefer to avoid.

Expectations:

  • Ability to specify multiple domains/prefixes in the config

    • Be able to specify which domain/prefix item config to use while constructing the short URL
    • Must be able to reuse the same identifier for the same shortened URL and be reuseable on all domin/prefixes
    • Use default if none is specified
    • Ability to add custom domain/prefixes on the fly

Thank you for this wonderful package and looking forward to your response on this enhancement.

@yordadev
Copy link
Member

Hey @KnightAR 👋🏼

First of all, thank you for such a nicely formatted issue & the kind words. 🙏🏼 🍻

This is a great feature request and I'm going to try and find time in the next ~two weeks to knock this out. Things are crazy right now since I am starting my last week of my masters, lots of hustling and bustling to get things done for my final submission.

If this is something you or anyone else is interesting in contributing towards the package before I get to it. The money maker for this change is ultimately here. We'll want to add a new Builder Option into the actual builder and place it in here. You'll want to implement it similar to how withPassword(string $password) is setup, except with withCustomBase(string $base_url) or something similar. It will allow the package to pivot the base domain here when building the short url.

UrlService::shorten('something-extremely-long.com/even/longer?ref=with&some=thingelselonger')
->withCustomBase('somethingcool.com')
->build(); 

// somethingcool.com/prefix/identifier

@yordadev yordadev added enhancement New feature or request good first issue Good for newcomers labels Apr 14, 2023
@yordadev
Copy link
Member

yordadev commented May 25, 2024

This is going in the v3 release that I've been actively working. I am hoping to get the release PR up next week or so for feedback.

UrlService::shorten('something-extremely-long.com/even/longer?ref=with&some=thingelselonger')
->withDomain('somethingcool.com')
->build(); 

// somethingcool.com/prefix/identifier

@KnightAR
Copy link
Author

Hi @yordadev,

Thanks for getting to this. There are a few things I implemented in my source code that makes the code work smoothly. Please consider the following:

Add an alternate branding config key thay allows you to switch between brandings: allow for the default branding to be the defaults and have the alternate override depending on your branding you want. Ie. Different domain, images, password settings, etc.

I hacked it all in my repo. I currently have 5 different domains with different brandings, host and prefix variations without having to manually set a custom host. This way yoy can just loop though and create the routes based off of them. Right now I'm manually setting the route.

I think this will cover my needs and give more flexibility to the overall package for other users needs.

Additional optional suggestion would be allowing the user to make a shortened url that can be resticted to that branding only, returning a 404 if its attempted on another branding.

Let me know what you think

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

No branches or pull requests

2 participants