UI-Router And Case-Sensitive URLs

Ilya Gelman

If you’ve ever encountered a situation where your URLs suddenly redirect to 404 when typed in all uppercase (if you haven’t, you should check your application for this issue anyway, because sometimes users do weird things like that), there is a simple solution.

Starting with version 0.2.11 of ui-router, you can make urls case insensitive with one config line:

angular.module('App').config(function ($urlMatcherFactoryProvider) {  
    $urlMatcherFactoryProvider.caseInsensitive(true);
})

$urlMatcherFactory also includes a number of interesting features, such as strictMode, which makes ui-router not match trailing slashes in urls. Check out these features in the ui-router docs.

Read docs, have fun!

Popular