jpmcgrath / shortener

Shortener makes it easy to create shortened URLs for your rails application.
MIT License
539 stars 225 forks source link

Restrict To Domain #128

Closed RailsCod3rFuture closed 4 years ago

RailsCod3rFuture commented 4 years ago

How can I specify the domain and reject the url if it does not include the correct domain. dragon.ruby.com/ or https://dragon.ruby.com/ http://dragon.ruby.com/* ?

jpmcgrath commented 4 years ago

I am not 100% sure what you are asking, but I think you would like to make it so shortened urls are only expanded when the request is made to a specific domain (on an app with multiple domains/subdomains). If this is correct, this would be achieved outside of the gem in your rails app's routing.

The alternative interpretation of your question is how to restrict the creation of shortened links to urls that start with a specific domain. If this is the case, you could wrapper the helper methods to include a conditional statement to check that the domain of the supplied url meets your requirements.