• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
route bug in _reindex_segments ?

#1
[eluser]Unknown[/eluser]
hello

I have a routing instruction :
Code:
//global redirect
// -any-thing/-begining/-with/-dash/is/cleared => is/cleared
$route['-[^/]*/(?:(?:-[^/]*/)+)?([^\-].*)'] = '$1';

so before call to _reindex_segments, we have
Code:
Router->segments = array('-any-thing', 'home', 'index', 'arg1');
Router->rsegments = array('home', 'index', 'arg1');

but inside, the test
Code:
$diff = (count(array_diff($this->rsegments, $this->segments)) == 0) ? FALSE : TRUE;
returns FALSE

I think it should be replaced with
Code:
$diff = (count(array_diff($this->rsegments, $this->segments)) +
        count(array_diff($this->segments, $this->rsegments)) == 0) ? FALSE : TRUE;
since the value isn't the same when you put segments or rsegments first...

#2
[eluser]Unknown[/eluser]
In case you do so, add this code to the end of the _validate_segments function:
Code:
if($this->fetch_directory()!='')
      array_unshift($this->rsegments, substr($this->fetch_directory(), 0, -1));

it will prevent bugs apearing when your controller is inside a subfolder, since now rsegment[1] would, without it, not be the name of the folder...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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