Skip to content

Commit

Permalink
ITV-2200 Deprecate the use of *history=broadcast
Browse files Browse the repository at this point in the history
- Pass through currentUrlParams to Historian
- Update usages of hash fragment to utilize query param
  • Loading branch information
acarlson0000 committed Dec 6, 2018
1 parent 015c72d commit 01f8642
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions static/script-tests/tests/application-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
// Configure BrowserDevice.getWindowLocation() to return canned data
this.sandbox.stub(BrowserDevice.prototype, 'getWindowLocation', function() {
return {
href: 'http://www.test.com/#&*history=broadcast'
href: 'http://www.test.com/?broadcast=true'
};
});

Expand All @@ -111,7 +111,7 @@
// Configure BrowserDevice.getWindowLocation() to return canned data
this.sandbox.stub(BrowserDevice.prototype, 'getWindowLocation', function() {
return {
href: 'http://www.test.com/#&*history=broadcast'
href: 'http://www.test.com/?broadcast=true'
};
});

Expand Down
8 changes: 4 additions & 4 deletions static/script-tests/tests/historian.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
'antie/historian'
],
function(Historian) {
var historian = new Historian('http://www.test.com/test/#&*history=broadcast');
var historian = new Historian('http://www.test.com/test/?broadcast=true');
assertFalse('hasHistory()', historian.hasHistory());
}
);
Expand All @@ -260,7 +260,7 @@
'antie/historian'
],
function(Historian) {
var historian = new Historian('http://www.test.com/test/#&*history=http://www.test2.com&*history=broadcast');
var historian = new Historian('http://www.test.com/test/?broadcast=true#&*history=http://www.test2.com');
assert('hasHistory()', historian.hasHistory());
}
);
Expand All @@ -273,7 +273,7 @@
'antie/historian'
],
function(Historian) {
var historian = new Historian('http://www.test.com/test/#&*history=http://www.test2.com&*history=broadcast');
var historian = new Historian('http://www.test.com/test/?broadcast=true#&*history=http://www.test2.com');
assert('hasBroadcastOrigin()', historian.hasBroadcastOrigin());
}
);
Expand All @@ -286,7 +286,7 @@
'antie/historian'
],
function(Historian) {
var historian = new Historian('http://www.test.com/test#&*history=broadcast');
var historian = new Historian('http://www.test.com/test?broadcast=true');
assert('hasBroadcastOrigin()', historian.hasBroadcastOrigin());
}
);
Expand Down
2 changes: 1 addition & 1 deletion static/script/devices/browserdevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ define(
* @returns {antie.Historian} an object that can be used to get a back or forward url between applications while preserving history
*/
getHistorian: function getHistorian () {
return new Historian(decodeURI(this.getWindowLocation().href));
return new Historian(decodeURI(this.getWindowLocation().href), this.getCurrentAppURLParams());
},

/**
Expand Down
11 changes: 6 additions & 5 deletions static/script/historian.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ define(
* @constructor
* @ignore
*/
init: function init (currentUrl) {
init: function init (currentUrl, UrlAppParams) {
var i;

this._urlParams = UrlAppParams;
this._historyArray = currentUrl.split(Historian.HISTORY_TOKEN);
this._currentUrl = this._historyArray.shift(); // non-history portion of the URL
for(i = 0; i !== this._historyArray.length; i += 1) {
Expand Down Expand Up @@ -121,16 +122,16 @@ define(
* @returns {Boolean} True if the history stack contains one or more valid return URLs.
*/
hasHistory: function hasHistory () {
var historyMinimumLength = this.hasBroadcastOrigin() ? 2 : 1;
var historyMinimumLength = 1;
return this._historyArray.length >= historyMinimumLength;
},

/**
* Returns a Boolean to indicate whether the first entry in the history stack is the special 'broadcast' entry.
* @returns {Boolean} True if the first entry in the history stack is the special 'broadcast' entry.
* Returns a Boolean to indicate whether the URL contains a 'broadcast' query parameter.
* @returns {Boolean} True if the URL contains a 'broadcast' query parameter.
*/
hasBroadcastOrigin: function hasBroadcastOrigin () {
return this._historyArray.length > 0 && this._historyArray[this._historyArray.length - 1] === Historian.HISTORY_TOKEN + Historian.BROADCAST_ENTRY;
return this._urlParams.length > 0 && this._urlParams[Historian.BROADCAST_ENTRY] === true;
}
});

Expand Down

0 comments on commit 01f8642

Please sign in to comment.