Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe routes has problem. [setTranslateURIDashes] #1564

Closed
eterv opened this issue Dec 1, 2018 · 5 comments
Closed

Maybe routes has problem. [setTranslateURIDashes] #1564

eterv opened this issue Dec 1, 2018 · 5 comments

Comments

@eterv
Copy link

eterv commented Dec 1, 2018

I use this config.
setTranslateURIDashes(true)

I think that if I connent 'users/login-process' (dash) then,
should be connected to 'login_process' (underscore) method of 'users' controller.
but contrary to my expectation, just I could see 404 page not found error page.
So, I've checked source.
I think that something important source is missing.

so now I'm using below modified code temporarily.

in: system/Router/Router.php :: autoRoute() function

if ( ! empty($segments))
{
	$this->method = array_shift($segments);
}

    /**
     * Added - BEGIN
     */
    if ($this->collection->shouldTranslateURIDashes()) {
        $this->translateURIDashes = true;
        $this->method = str_replace('-', '_', $this->method);
    }
    /**
     * Added - END
     */

So, could you please check this point?

@bangbangda
Copy link
Contributor

Controller name also needs to be converted.
check this PR. do you think it is okay?

@eterv
Copy link
Author

eterv commented Dec 2, 2018

Controller name also needs to be converted.
check this PR. do you think it is okay?

Yes. Exactly!
I checked PR.

but, even if I use $routes->setTranslateURIDashes(true) in app/Config/routes.php file, there is no change.
the $translateURIDashes variable in Router (not Routes) still value is false.
so, I used $this->translateURIDashes = true; in above my example code.

I think that setTranslateURIDashes() function in Router needs to be called somewhere.

could you please check this?

@lonnieezell
Copy link
Member

@eterv Just pushed a potential fix, please let me know if it works for you. It is based off of what @bangbangda did, but I think he missed one place.

@eterv
Copy link
Author

eterv commented Dec 19, 2018

@lonnieezell thank you for your help and code.

but, I think that need to add below one line code.

in CodeIgniter.php :: tryToRouteIt() method

// Already exist...
$this->router = Services::router($routes);
// A new line
$this->router->setTranslateURIDashes($routes->shouldTranslateURIDashes());

// Already exists...
$path = $this->determinePath();

After modify it then, finally there is no any problem in auto route.

So, could you please consider and test it?

@lonnieezell
Copy link
Member

Good catch. Thanks. Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants