Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Protocol-less BASE URI doesn't work #5292

Closed
gromgull opened this issue Dec 5, 2013 · 6 comments
Closed

Protocol-less BASE URI doesn't work #5292

gromgull opened this issue Dec 5, 2013 · 6 comments

Comments

@gromgull
Copy link

gromgull commented Dec 5, 2013

Ideally I'd like to have

<base href="//myserver.com"> 

in my HTML, so that I can serve http and https from the same folder. But Angular then falls over with a:

TypeError: Cannot call method 'indexOf' of undefined
    at beginsWith (http://localhost:5012/js/vendor/angular/angular.js:8405:13)
    at Object.$$parse (http://localhost:5012/js/vendor/angular/angular.js:8448:19)
    at $LocationProvider.$get (http://localhost:5012/js/vendor/angular/angular.js:8960:15)
    at Object.invoke (http://localhost:5012/js/vendor/angular/angular.js:3646:28)
    at http://localhost:5012/js/vendor/angular/angular.js:3479:37
    at getService (http://localhost:5012/js/vendor/angular/angular.js:3600:39)
    at Object.invoke (http://localhost:5012/js/vendor/angular/angular.js:3622:13)
    at http://localhost:5012/js/vendor/angular/angular.js:3479:37
    at getService (http://localhost:5012/js/vendor/angular/angular.js:3600:39)
    at Object.invoke (http://localhost:5012/js/vendor/angular/angular.js:3622:13) 
@siddii
Copy link
Contributor

siddii commented Jan 2, 2014

@gromgull - The following code seems to work fine for me. I couldn't create a plunkr or jsfiddle coz none of them works on both http & https.

<!DOCTYPE html>
<html>
<head>
    <base href="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0/">
    <script src="angular.min.js"></script>
    <script>
        angular.module('test-app',[]).run(function ($location) {
            console.log('##### $location = ', $location.absUrl());
        });
    </script>
</head>
<body ng-app="test-app">
<div>{{1 + 1}}</div>
</body>
</html>

@caitp
Copy link
Contributor

caitp commented Jan 2, 2014

A reproduction would be awesome, could probably make a quick heroku app to repro it maybe.. I've got nothing better to do so I guess I'll have a go at it

@caitp
Copy link
Contributor

caitp commented Jan 2, 2014

I've put up a quick repro on http://ng-5292.herokuapp.com/ --- I don't think I can totally reproduce your issue, but I do see another one, which is that the appBase url seems to be incorrect because of the leading '/', so it fails to figure out that it's an absolute url. I'll work on a patch

@caitp
Copy link
Contributor

caitp commented Jan 12, 2014

@gromgull can you check if the above patch fixed your issue? Would be good to close this if it did

@gromgull
Copy link
Author

@caitp : That seems to have fixed it, thanks!

@caitp
Copy link
Contributor

caitp commented Jan 14, 2014

Marking this as closed by 760f2fb

Please re-open if there are any other related concerns

@caitp caitp closed this as completed Jan 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants