diff --git a/bower.json b/bower.json index 02fabd2..5ee765c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "cross-storage", - "version": "0.6.0", + "version": "0.6.1", "description": "Cross domain local storage", "license": "Apache-2.0", "authors": [ diff --git a/dist/client.js b/dist/client.js index c8aab28..bd56c21 100644 --- a/dist/client.js +++ b/dist/client.js @@ -1,7 +1,7 @@ /** * cross-storage - Cross domain local storage * - * @version 0.6.0 + * @version 0.6.1 * @link https://github.com/zendesk/cross-storage * @author Daniel St. Jules * @copyright Zendesk @@ -100,7 +100,7 @@ CrossStorageClient.frameStyle = { * @returns {string} The origin of the url */ CrossStorageClient._getOrigin = function(url) { - var uri, origin; + var uri, protocol, origin; uri = document.createElement('a'); uri.href = url; @@ -109,7 +109,13 @@ CrossStorageClient._getOrigin = function(url) { uri = window.location; } - origin = uri.protocol + '//' + uri.host; + if (!uri.protocol || uri.protocol === ':') { + protocol = window.location.protocol; + } else { + protocol = uri.protocol; + } + + origin = protocol + '//' + uri.host; origin = origin.replace(/:80$|:443$/, ''); return origin; diff --git a/dist/client.min.js b/dist/client.min.js index e40bc2a..bb330c0 100644 --- a/dist/client.min.js +++ b/dist/client.min.js @@ -1,11 +1,11 @@ /** * cross-storage - Cross domain local storage * - * @version 0.6.0 + * @version 0.6.1 * @link https://github.com/zendesk/cross-storage * @author Daniel St. Jules * @copyright Zendesk * @license Apache-2.0 */ -function CrossStorageClient(e,t){t=t||{},this._id=CrossStorageClient._generateUUID(),this._promise=t.promise||Promise,this._frameId=t.frameId||"CrossStorageClient-"+this._id,this._origin=CrossStorageClient._getOrigin(e),this._requests={},this._connected=!1,this._closed=!1,this._count=0,this._timeout=t.timeout||3e3,this._listener=null,this._installListener();var r;t.frameId&&(r=document.getElementById(t.frameId)),r&&this._poll(),r=r||this._createFrame(e),this._hub=r.contentWindow}CrossStorageClient.frameStyle={display:"none",position:"absolute",top:"-999px",left:"-999px"},CrossStorageClient._getOrigin=function(e){var t,r;return t=document.createElement("a"),t.href=e,t.host||(t=window.location),r=t.protocol+"//"+t.host,r=r.replace(/:80$|:443$/,"")},CrossStorageClient._generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,r="x"==e?t:3&t|8;return r.toString(16)})},CrossStorageClient.prototype.onConnect=function(){var e=this;return this._connected?this._promise.resolve():this._closed?this._promise.reject(new Error("CrossStorageClient has closed")):(this._requests.connect||(this._requests.connect=[]),new this._promise(function(t,r){var o=setTimeout(function(){r(new Error("CrossStorageClient could not connect"))},e._timeout);e._requests.connect.push(function(e){return clearTimeout(o),e?r(e):(t(),void 0)})}))},CrossStorageClient.prototype.set=function(e,t,r){return this._request("set",{key:e,value:t,ttl:r})},CrossStorageClient.prototype.get=function(){var e=Array.prototype.slice.call(arguments);return this._request("get",{keys:e})},CrossStorageClient.prototype.del=function(){var e=Array.prototype.slice.call(arguments);return this._request("del",{keys:e})},CrossStorageClient.prototype.clear=function(){return this._request("clear")},CrossStorageClient.prototype.getKeys=function(){return this._request("getKeys")},CrossStorageClient.prototype.close=function(){var e=document.getElementById(this._frameId);e&&e.parentNode.removeChild(e),window.removeEventListener?window.removeEventListener("message",this._listener,!1):window.detachEvent("onmessage",this._listener),this._connected=!1,this._closed=!0},CrossStorageClient.prototype._installListener=function(){var e=this;this._listener=function(t){var r,o,s;if(!e._closed&&t.origin===e._origin)if("cross-storage:unavailable"!==t.data){if(-1!==t.data.indexOf("cross-storage:")&&!e._connected){if(e._connected=!0,!e._requests.connect)return;for(r=0;r * @copyright Zendesk diff --git a/dist/hub.min.js b/dist/hub.min.js index f23dec7..980935b 100644 --- a/dist/hub.min.js +++ b/dist/hub.min.js @@ -1,7 +1,7 @@ /** * cross-storage - Cross domain local storage * - * @version 0.6.0 + * @version 0.6.1 * @link https://github.com/zendesk/cross-storage * @author Daniel St. Jules * @copyright Zendesk diff --git a/package.json b/package.json index 642f713..c975ae4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cross-storage", - "version": "0.6.0", + "version": "0.6.1", "description": "Cross domain local storage", "keywords": [ "local",