Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

bug in isAnonymousEndpoint() if templateUrl is a function instead of string #368

Closed
dhodgin opened this issue Aug 22, 2016 · 2 comments
Closed
Assignees
Milestone

Comments

@dhodgin
Copy link
Contributor

dhodgin commented Aug 22, 2016

per the angular documentation the templateUrl can be either a string or a function. if it is a function it is passed the params of the route

see: https://docs.angularjs.org/api/ngRoute/provider/$routeProvider

in the adal-angular code

function isAnonymousEndpoint(url)

there is a url.indexOf() call. If your templateUrl for this route is a function you will get a console error that url.indexOf is not a function because url is a function that will return a string if involked with the params of the upcoming route.

we use a function for one of our routes to manipulate one of the params so the page title can be dynamically updated using the param value.

everytime we hit this route we get this error.

I'm attempting to patch this by checking if the url is a function and then involking it first to get the string value back before calling the .indexOf() but i'm having trouble getting access to the params of the upcoming route to involk the templateUrl function.

i've tried $routeParams and $route.current.params as per angular docs to try to acces the params for the route but i'm either getting nothing or the current route

the other option is to change the routeChangeHandler and stateChangeHandler functions and check the params there before calling the isAnonymousEndpoint function all together.

as far as i can see those are the only 2 places isAnonymousEndpoint is called in adal-angular so it could be easy to modify

i've also tried adding the path to the template to my anonymous endpoints array in my init but it doesn't stop the error because it's still going to end up passing the function reference to isAnonymousEndpoint in the handler code regardless.

@tushargupta51
Copy link
Contributor

@rohitnarula7176 can you please take a look?

@dhodgin
Copy link
Contributor Author

dhodgin commented Aug 22, 2016

i've got a patch that can fix it for the routeChangeHandler that i can put up in the next 2 hours but we don't use ui-router so i can't trigger the stateChangeHandler to test if the toParams will give me what i need to handle this problem on a state change

i can put up the patch to fix the routeChangeHandler though and someone else who uses ui-router can patch stateChangeHandler separately

tushargupta51 added a commit that referenced this issue Aug 25, 2016
add support for templateUrl that is a function. fixes #368
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants