Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

Upgrading Angular to 1.3.8 and adding a fix #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

saravmajestic
Copy link
Contributor

#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

Fixing trailing slash issue - when navigating from home to any city (ex: boston) and reload the page, somehow '\' is added to the end of location.href, which breaks the routing.
This code will remove the trailing slash
Taken from angular-ui/ui-router#50 (comment)
Adding "base" tag since it is mandatory for angular 1.3.x versions
@saravmajestic saravmajestic mentioned this pull request Jan 10, 2015
@apparentlymart
Copy link
Collaborator

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
Copy link
Contributor Author

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
Copy link
Collaborator

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
Copy link
Contributor Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants