-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat($location): default hashPrefix to '!' #14202
Conversation
47757f7
to
5b0a007
Compare
}); | ||
}); | ||
|
||
it('should not be hashbang mode', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this test identical with the above ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of the test may be identical but the sentiment is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the description of this test should be should not be htm5mode
Will old links get redirected to the new #! url?
|
@aciccarello, nope. That's part of the breaking change. |
Implementation-wise it LGTM. I'm not yet convinced about this change (from a theoretical point of view), but it sure doesn't hurt (and it's easy to "work around" it for backward compatibility). Assuming this won't change anything in terms of how search engines treat |
The $location service is designed to support hash prefixed URLs for cases where the browser does not support HTML5 push-state navigation. The Google Ajax Crawling Scheme expects that local paths within a SPA start with a hash-bang (e.g. `somedomain.com/base/path/#!/client/side/path`). The `$locationProvide` allows the application developer to configure the hashPrefix, and it is normal to set this to a bang '!', but the default has always been the empty string ''. This has caused some confusion where a user is not aware of this feature and wonders why adding a hash value to the location (e.g. `$location.hash('xxx')`) results in a double hash: `##xxx`. This commit changes the default value of the prefix to '!', which is more natural and expected. See https://developers.google.com/webmasters/ajax-crawling/docs/getting-started Closes angular#13812 BREAKING CHANGE The hash-prefix for `$location` hash-bang URLs has changed from the empty string "" to the bang "!". If your application does not use HTML5 mode or is being run on browsers that do not support HTML5 mode, and you have not specified your own hash-prefix then client side URLs will now contain a "!" prefix. For example, rather than `mydomain.com/#/a/b/c` will become `mydomain/#!/a/b/c`. If you actually wanted to have no hash-prefix then you should configure this by adding a configuration block to you application: ``` appModule.config(['$locationProvider', function($locationProvider) { $locationProvider.hashPrefix(""); }]); ```
5b0a007
to
5ee1f00
Compare
The default navigation hash prefix has changed from '' to '!' in Angular 1.6: angular/angular.js#14202
The $location service is designed to support hash prefixed URLs
for cases where the browser does not support HTML5 push-state navigation.
The Google Ajax Crawling Scheme expects that local paths within a SPA start
with a hash-bang (e.g.
somedomain.com/base/path/#!/client/side/path
).The
$locationProvide
allows the application developer to configure thehashPrefix, and it is normal to set this to a bang '!', but the default
has always been the empty string ''.
This has caused some confusion where a user is not aware of this feature
and wonders why adding a hash value to the location (e.g.
$location.hash('xxx')
)results in a double hash:
##xxx
.This commit changes the default value of the prefix to '!', which is more
natural and expected.
See https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
Closes #13812
BREAKING CHANGE
The hash-prefix for
$location
hash-bang URLs has changed from the emptystring "" to the bang "!". If your application does not use HTML5 mode
or is being run on browsers that do not support HTML5 mode, and you have
not specified your own hash-prefix then client side URLs will now contain
a "!" prefix. For example, rather than
mydomain.com/#/a/b/c
will becomemydomain/#!/a/b/c
.If you actually wanted to have no hash-prefix then you should configure
this by adding a configuration block to you application: