• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter 3.0-dev - routes urls

#1
[eluser]ariel_esp[/eluser]
Hi guys,

I using CI 2.1.3, my system work fine... with HMVC
I have a admin painel, where there is a search form that final url is variable... as:
domain.com/admin/users/search/ -> home
domain.com/admin/users/search/1/ -> pagination
domain.com/admin/users/search/1/text/text/etc -> text = search query 1, search query 2, etc ...

working fine...

but.. I started test with CI 3.0-dev ... using same base routes and modules.. etc
So, the routes work... but, I cant using ilimited search querys like above...
Return 404

domain.com/admin/users/search/ -> home - OK
but...
domain.com/admin/users/search/1/ -> pagination
domain.com/admin/users/search/1/text/text/etc -> text = search query 1, search query 2, etc ...
dont work because roles in route not specific with all blocks "/"

routes.php example : working fine in 2.1.3 for my projects::
$route['([a-zA-Z_-]+)/([a-zA-Z_-]+)/(:any)'] = "$2/$1/$3";

In resume, my idea in url are: controller/module/function / parameter1 / parameter2 / etc....

---
So, any idea why stopped work in 3.0-dev ?

#2
[eluser]ariel_esp[/eluser]
I replaced system/application/core/Router.php with 2.1.3 version and work fine now... why? Are there bugs !?

#3
[eluser]ariel_esp[/eluser]
I founded the bug::::
/system/core/Router.php

protected function _parse_routes()

// Convert wild-cards to RegEx
// original 3.0 - bugged
// $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);

// original 2.1.3 - working
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));

#4
[eluser]CroNiX[/eluser]
File a bug report on github or it probably won't be noticed or looked at.

#5
[eluser]Unknown[/eluser]
Actually, your fix is the "bug".

There's information on this in the user guide for 3.0-dev - I'll go ahead and copy/paste it here though.

--

Historically, CodeIgniter has always provided the :any wildcard in routing,
with the intention of providing a way to match any character within an URI segment.

However, the :any wildcard is actually just an alias for a regular expression
and used to be executed in that manner as .+. This is considered a bug, as it
also matches the / (forward slash) character, which is the URI segment delimiter
and that was never the intention. In CodeIgniter 3, the :any wildcard will now
represent [^/]+, so that it will not match a forward slash.

There are certainly many developers that have utilized this bug as an actual feature.
If you're one of them and want to match a forward slash, please use the .+
regular expression::

(.+) // matches ANYTHING
(:any) // matches any character, except for '/'


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.