Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I am using angular-ui-router in my angular application. I want to make URLs in my application case insensitive. I explored in stack overflow and one of the answers here suggested me to use this code in the app config:

$urlRouterProvider.rule(function ($injector, $location) {
        //what this function returns will be set as the $location.url
        var path = $location.path(), normalized = path.toLowerCase();
        if (path != normalized) {
            //instead of returning a new url string, I'll just change the $location.path directly so I don't have to worry about constructing a new url string and so a new state change is not triggered
            $location.replace().path(normalized);
        }
        // because we've returned nothing, no state change occurs
        //return $location.absUrl(normalized);
    });

However it doesn't work for me and my application returns back to the home page(when trying to alter the case in URL) since my default router page setting is (/Home). When the url changes, I want the code to load the corresponding template and invoke its corresponding controller. What am I doing wrong?

share|improve this question
    
instaed of $location..replace().path(normalized); use $location.replace().path(normalized); – user1794058 May 20 '14 at 7:15
    
that's a mistake while copying into question. I've corrected it. – Adarsh Konchady May 20 '14 at 10:06
    
I still have the problem. Can someone help? – Adarsh Konchady May 25 '14 at 14:15

I know this is an old question but it might still help someone who is facing a similar issue.

Since you are normalizing the URL to lowercase, make sure the URL in your state configurations is also lower case.

For example, this will not work:

$stateProvider.state('state1', { url: '/STATE1' ...

This will work:

$stateProvider.state('state1', { url: '/state1' ...
share|improve this answer
    
URL in state configuration was in lower case itself. But it wasn't working for me. – Adarsh Konchady Mar 4 '15 at 17:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.