revert: fix($location): parse query string when path is empty in hashbang mode

This reverts commit cad717b117.

This change causes regressions in existing code and after closer inspection
I realized that it is trying to fix an issue that is should not be considered
a valid issue.

The location service was designed to work against either "hash" part of the
window.location when in the hashbang mode or full url when in the html5 mode.

This change tries to merge the two modes partially, which is not right. One
reason for this is that the search part of window.location can't be modified
while in the hashbang mode (a browser limitation), so with this change part
of the search object should be immutable and read-only which will only cause
more confusion.

Relates to #5964
This commit is contained in:
Igor Minar
2014-02-25 22:59:31 -08:00
parent 6b049c74cc
commit 3d6dff44f3
2 changed files with 2 additions and 35 deletions

View File

@@ -178,11 +178,6 @@ function LocationHashbangUrl(appBase, hashPrefix) {
throw $locationMinErr('ihshprfx', 'Invalid url "{0}", missing hash prefix "{1}".', url,
hashPrefix);
}
if (withoutHashUrl === '' && withoutBaseUrl.charAt(0) === '?') {
withoutHashUrl = withoutBaseUrl;
}
parseAppUrl(withoutHashUrl, this, appBase);
this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);
@@ -233,14 +228,10 @@ function LocationHashbangUrl(appBase, hashPrefix) {
*/
this.$$compose = function() {
var search = toKeyValue(this.$$search),
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '',
url = '';
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
if (this.$$url) {
url = this.$$path ? hashPrefix + this.$$url : this.$$url;
}
this.$$absUrl = appBase + url;
this.$$absUrl = appBase + (this.$$url ? hashPrefix + this.$$url : '');
};
this.$$rewrite = function(url) {

View File

@@ -1487,30 +1487,6 @@ describe('$location', function() {
expect(location.url()).toBe('/not-starting-with-slash');
expect(location.absUrl()).toBe('http://server/pre/index.html#/not-starting-with-slash');
});
describe("search()", function() {
it("should return a populated search object for search query when path is empty", function() {
location = new LocationHashbangUrl('http://server/pre/index.html', '!');
location.$$parse('http://server/pre/?foo=1&bar=2&baz=3');
expect(location.path()).toBe('');
expect(location.absUrl()).toBe('http://server/pre/index.html?foo=1&bar=2&baz=3')
expect(location.search()).toEqual({
foo: '1',
bar: '2',
baz: '3'
});
location.$$parse('http://server/pre/index.html?foo=1&bar=2&baz=3');
expect(location.path()).toBe('');
expect(location.absUrl()).toBe('http://server/pre/index.html?foo=1&bar=2&baz=3')
expect(location.search()).toEqual({
foo: '1',
bar: '2',
baz: '3'
});
});
});
});