saymedia / angularjs-server

Specialized server for AngularJS sites
MIT License
247 stars 49 forks source link

Upgrading Angular to 1.3.8 and adding a fix #16

Open saravmajestic opened 9 years ago

saravmajestic commented 9 years ago

1 - upgraded to angular 1.3.8 version

2 - tested with express version 4.10.7

3 - Added a fix for trailing slash during page reload

apparentlymart commented 9 years ago

Hello!

Thanks for this change and sorry for taking so long to get back to you. I've merged the second of your commits already. I have some questions about the trailing slash issue, though:

In the stock angular $route service, a redirection route is automatically created to either add or remove a trailing slash, depending on whether the canonical URL already includes a trailing slash. This behavior is mimicked by AngularJS-server here: https://github.com/saymedia/angularjs-server/blob/master/lib/ngoverrides.js#L638

The intended behavior is that AngularJS-server would respect the redirection routes so that the server behaves the same way as the client would: emitting a redirect to the normalized URL.

It looks like this isn't working quite right in the demo. If you access this URL then you get a blank page, rather than the redirection that was expected: http://angularjs-server-weather.herokuapp.com/boston/

However, I think the fix here is not to ignore the trailing slash but rather to consider the trailing slash and handle the redirect route so that the browser ends up at this URL: http://angularjs-server-weather.herokuapp.com/boston

Would you agree that this seems sensible?

saravmajestic commented 9 years ago

Hi, If we handle the trailing slash and do another redirection without trailing slash, would that be considered as another redirect in browser? If so, this might be like 2 redirections right?

Thanks.

apparentlymart commented 9 years ago

I think there should be only one redirection: /boston/ will redirect to /boston and then the page will render as normal. Do I misunderstand?

saravmajestic commented 9 years ago

if it is so, your idea should be the correct way to implement!