mihatorikei / codeigniter-vitejs

ViteJS Integration For Codeigniter4 🔥⚡
MIT License
89 stars 10 forks source link

Vite not loaded on "/" route #31

Open gresakg opened 4 months ago

gresakg commented 4 months ago

CodeIgniter version: 4.5.1 Package version: 1.1.1

Vite is not loaded it the route is defined as $routes->get('/', 'FrontPage::display');

Vite should be loaded on all but the excluded routes.

The bug is in Vite::routeIsNotExcluded()

If you explode an empty string, you get an array with one member containing an empty string. When you compare it to the output of the uri_string() function on the route defined as "/", the result is bool true , which resolves the function to bool false so the route gets excluded.

You should probably first check if VITE_EXCLUDED_ROUTES is empty and just return bool true and only explode it if not empty.

The issue #30 may be connected with this.