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

Got something to add?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s