Repository: auth0/auth0.js (js)

Issue:
9.1.2: Error with redirectUri origin
Since the latest version 9.1.2 I get an error:
"The redirectUri's origin (http://localhost) should match the window's origin (http://localhost:3010)."

I'm pretty sure its because of this commit: https://github.com/auth0/auth0.js/commit/ceed49706f9af24eaf49ad21b778cad0d0ca3b49

Since the port is omitted, it won't use the correct port.

When I go back to previous version 9.1.0, it works great.

Pull request description:
Use origin.port when available
fix #640

Patch:
diff --git a/src/helper/object.js b/src/helper/object.js
index 4151f68..f82fb7b 100644
--- a/src/helper/object.js
+++ b/src/helper/object.js
@@ -125,7 +125,11 @@ function getOriginFromUrl(url) {
   var doc = windowHelper.getDocument();
   var anchor = doc.createElement('a');
   anchor.href = url;
-  return anchor.protocol + '//' + anchor.hostname;
+  var origin = anchor.protocol + '//' + anchor.hostname;
+  if (anchor.port) {
+    origin += ':' + anchor.port;
+  }
+  return origin;
 }
 
 module.exports = {


Test patch:
diff --git a/test/helper/object.test.js b/test/helper/object.test.js
index aa6d316..440ba87 100644
--- a/test/helper/object.test.js
+++ b/test/helper/object.test.js
@@ -540,5 +540,24 @@ describe('helpers', function() {
       expect(anchor.href).to.be(url);
       windowHelper.getDocument.restore();
     });
+    it('should use add the `port` when available', function() {
+      var anchor = {
+        protocol: 'https:',
+        hostname: 'localhost',
+        port: 3000
+      };
+      stub(windowHelper, 'getDocument', function() {
+        return {
+          createElement: function createElement(e) {
+            expect(e).to.be('a');
+            return anchor;
+          }
+        };
+      });
+      var url = 'https://localhost:3000/example';
+      expect(objectHelper.getOriginFromUrl(url)).to.be('https://localhost:3000');
+      expect(anchor.href).to.be(url);
+      windowHelper.getDocument.restore();
+    });
   });
 });