AngularJS 1.x url case sensitivity

In case you didn’t know the routes that configured using UI-Router are case-sensitive.  Which is definitely not what I would expect. To get around this problem you can add a snippet of code to the _Layout.cshtml page (in the body tag).

<!– The following code fixes a AngularJS case sensitivity issue –>
<!– by replacing the base.href with the location.href –>

<script type=”text/javascript”>

(function () {

var base = document.querySelector(“base”);

var normalized = RegExp(base.href, “i”).exec(location.href);

base.href = normalized ? normalized[0] : base.href;

}());

</script>

Advertisements