diff --git a/browserid/static/dialog/controllers/authenticate_controller.js b/browserid/static/dialog/controllers/authenticate_controller.js index b9164e931e21cc885641a3d80c1154c60f439629..0054f37c37efc626e98afa6d5eccc40c7a86089b 100644 --- a/browserid/static/dialog/controllers/authenticate_controller.js +++ b/browserid/static/dialog/controllers/authenticate_controller.js @@ -192,7 +192,7 @@ this._super(el, { bodyTemplate: "authenticate.ejs", bodyVars: { - sitename: user.getOrigin(), + sitename: user.getHostname(), email: options.email || "" } }); diff --git a/browserid/static/dialog/controllers/dialog_controller.js b/browserid/static/dialog/controllers/dialog_controller.js index 1f369bdba719e4f562bb4a5e57b15fe2f52e9fe8..491d983fabfa5bced7d4e27424bf97ac90c57715 100644 --- a/browserid/static/dialog/controllers/dialog_controller.js +++ b/browserid/static/dialog/controllers/dialog_controller.js @@ -63,7 +63,7 @@ user.setOrigin(origin_url); // get the cleaned origin. - $("#sitename").text(user.getOrigin()); + $("#sitename").text(user.getHostname()); this.doCheckAuth(); diff --git a/browserid/static/dialog/resources/user.js b/browserid/static/dialog/resources/user.js index 57a4917957badd5974528d295b870819afcd618c..27105f7f4e798961bd9669063cb850501671b9d1 100644 --- a/browserid/static/dialog/resources/user.js +++ b/browserid/static/dialog/resources/user.js @@ -210,6 +210,15 @@ BrowserID.User = (function() { return origin; }, + /** + * Get the hostname for the set origin + * @method getHostname + * @returns {string} + */ + getHostname: function() { + return origin.replace(/^.*:\/\//, "").replace(/:\d*$/, ""); + }, + /** * Create a user account - this creates an user account that must be verified. * @method createUser diff --git a/browserid/static/dialog/test/qunit/resources/user_unit_test.js b/browserid/static/dialog/test/qunit/resources/user_unit_test.js index ae2791b7e1d5444961c9965a117cc1dd235adaa7..7e0b15155355d61d644a5aa3a48ff7d92079ece7 100644 --- a/browserid/static/dialog/test/qunit/resources/user_unit_test.js +++ b/browserid/static/dialog/test/qunit/resources/user_unit_test.js @@ -221,6 +221,14 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/user", functio equal(lib.getOrigin(), testOrigin); }); + test("setOrigin, getHostname", function() { + var origin = "http://testorigin.com:10001"; + lib.setOrigin(origin); + + var hostname = lib.getHostname(); + equal(hostname, "testorigin.com", "getHostname returns only the hostname"); + }); + test("getStoredEmailKeypairs", function() { var identities = lib.getStoredEmailKeypairs(); equal("object", typeof identities, "we have some identities");