0

My project requires me to know what file extension was used while calling a route.

For example, If the route was 127.0.0.1/controller/action/filea.json Then then I would need to have a function that returns ".json" when called from inside action function "get_action".

If the route was 127.0.0.1/controller/action2/fileb.xml Then then the function should return ".xml" when called from inside action function "get_action2".

Right now, I tried using \URI::current(), but that only gets me "127.0.0.1/controller/action/filea" or "127.0.0.1/controller/action2/fileb"

Nitro
  • 1,063
  • 1
  • 7
  • 17

1 Answers1

0

Whether or not the extension is used is controlled by the config key routing.strip_extension, which is true by default.

The current extension can be retrieved using \Input::extension().

WanWizard
  • 2,574
  • 15
  • 13