AngularJS + Base Href Case Sensitive?

前端 未结 6 887
情话喂你
情话喂你 2020-12-10 13:43

I\'m struggling to understand why my base href seems to be case sensitive. I have a page with a base href and utilizes angularjs routing.

html:

<         


        
6条回答
  •  时光取名叫无心
    2020-12-10 14:33

    Had the same problem but have a different solution. This works for me and doesn't interfere with routing, beginsWith or the assumption that things are/should be lower case.

    Put this before angular is initialized (like in the head of your html page)

    // Fix base url being case sensitive
    (function () {
         var base = document.querySelector("base");
         var normalized = RegExp(base.href, "i").exec(location.href);
         base.href = normalized ? normalized[0] : base.href;
    }());
    

提交回复
热议问题