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

feat($location): default hashPrefix to '!' #14202

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ libpeerconnection.log
npm-debug.log
/tmp/
/scripts/bower/bower-*
.vscode
4 changes: 2 additions & 2 deletions docs/content/guide/$location.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ To configure the `$location` service, retrieve the

- **hashPrefix(prefix)**: {string}<br />
prefix used for Hashbang URLs (used in Hashbang mode or in legacy browser in Html5 mode)<br />
default: `""`
default: `"!"`

### Example configuration
```js
$locationProvider.html5Mode(true).hashPrefix('!');
$locationProvider.html5Mode(true).hashPrefix('*');
```

## Getter and setter methods
Expand Down
3 changes: 2 additions & 1 deletion src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ function locationGetterSetter(property, preprocess) {
* Use the `$locationProvider` to configure how the application deep linking paths are stored.
*/
function $LocationProvider() {
var hashPrefix = '',
var hashPrefix = '!',
html5Mode = {
enabled: false,
requireBase: true,
Expand All @@ -712,6 +712,7 @@ function $LocationProvider() {
* @ngdoc method
* @name $locationProvider#hashPrefix
* @description
* The default value for the prefix is `'!'`.
* @param {string=} prefix Prefix for hash part (containing path and search)
* @returns {*} current value if used as getter or itself (chaining) if used as setter
*/
Expand Down
14 changes: 7 additions & 7 deletions test/ng/browserSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,9 @@ describe('browser', function() {
$rootScope.$apply(function() {
$location.path('/initialPath');
});
expect(fakeWindow.location.href).toBe('http://server/#/initialPath');
expect(fakeWindow.location.href).toBe('http://server/#!/initialPath');

fakeWindow.location.href = 'http://server/#/someTestHash';
fakeWindow.location.href = 'http://server/#!/someTestHash';

$rootScope.$digest();

Expand All @@ -774,9 +774,9 @@ describe('browser', function() {
$rootScope.$apply(function() {
$location.path('/initialPath');
});
expect(fakeWindow.location.href).toBe('http://server/#/initialPath');
expect(fakeWindow.location.href).toBe('http://server/#!/initialPath');

fakeWindow.location.href = 'http://server/#/someTestHash';
fakeWindow.location.href = 'http://server/#!/someTestHash';

$rootScope.$digest();

Expand All @@ -793,9 +793,9 @@ describe('browser', function() {
$rootScope.$apply(function() {
$location.path('/initialPath');
});
expect(fakeWindow.location.href).toBe('http://server/#/initialPath');
expect(fakeWindow.location.href).toBe('http://server/#!/initialPath');

fakeWindow.location.href = 'http://server/#/someTestHash';
fakeWindow.location.href = 'http://server/#!/someTestHash';

$rootScope.$digest();

Expand Down Expand Up @@ -846,7 +846,7 @@ describe('browser', function() {
$rootScope.$digest();

// from $location for rewriting the initial url into a hash url
expect(browser.url).toHaveBeenCalledWith('http://server/#/some/deep/path', true);
expect(browser.url).toHaveBeenCalledWith('http://server/#!/some/deep/path', true);
expect(changeUrlCount).toBe(1);
});

Expand Down
Loading