1. Michael P. Jung
  2. opoge-pusher

Commits

Michael P. Jung  committed f5f82e3

Pass autodetected CORS domain to tunnel iframe

  • Participants
  • Parent commits f58352d
  • Branches master

Comments (0)

Files changed (2)

File opoge/pusher/static/consumer.js

View file
 	}
 	var ns = this.opoge.pusher;
 
-	// Autodetect URL for tunnel iframe
 	var scriptUrl = $('script').last().attr('src');
-	var tunnelUrl = scriptUrl.match('^(.*)/consumer\.js$')[1] + '/tunnel/';
 
 	function domainFromUrl(url) {
 		var m = url.match(/^https?:\/\/([^:\/]+)/);
 
 	var corsDomain = commonDomain(document.domain, tunnelDomain);
 
-	document.domain = corsDomain;
+	try {
+		document.domain = corsDomain;
+	} catch(e) {
+		alert(e);
+	}
+
+	// Autodetect URL for tunnel iframe and pass corsDomain
+	var tunnelUrl = scriptUrl.match('^(.*)/consumer\.js$')[1] +
+			'/tunnel/#' + corsDomain
 
 	/**
 	 * opoge.pusher.Consumer

File opoge/pusher/templates/tunnel.html

View file
 	<script type="text/javascript" src="%(jquery_js)s"></script>
 	<script type="text/javascript">
 		try {
-			document.domain = "%(domain)s";
+			document.domain = location.hash.replace(/^#/, '');
 		} catch(e) {
 			alert(e);
 		}