1

My Routes:

Get().route('/amp/@website', 'PageController@amp_info').name('amp_info'),
Get().route('/@website', 'PageController@info').name('info')

This works: https://websiteopedia.com/www.eventsnow.com this does not https://websiteopedia.com/https://www.eventsnow.com/

What do I need to do differently? the slash in params redirected to the 404 as it didn't find any matching route

Vaibhav Mule
  • 5,016
  • 4
  • 35
  • 52

1 Answers1

1

Yes, in order to achieve this you have two options: using inputs or creating a route compiler

Using Inputs

You can make the url simply go to the info method with nothing special in the url:

Get().route('/', 'PageController@info').name('info')

Then you can hit routes like https://websiteopedia.com/?website=https://www.eventsnow.com/

Then inside the info method, you would get the input as normal:

def info(self, request: Request):
    request.input('website') #== 'https://www.eventsnow.com/'

Route Compiler

A route compiler is simply a way to compile regex in the URL. You can make a new compiler in one of the boot methods in your service providers.

This new compiler would look like this:

def boot(self, view: View):
    view.compile('url', r'([^\s]+)')

Then you can construct the route like this:

Get().route('/@website:url', 'PageController@info').name('info')

This will now compile that into the regex you provided and you can now hit the routes like you were previously.

Joseph Mancuso
  • 403
  • 5
  • 11