summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/gaia_auth/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/browser/resources/gaia_auth/util.js')
-rw-r--r--chromium/chrome/browser/resources/gaia_auth/util.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/chromium/chrome/browser/resources/gaia_auth/util.js b/chromium/chrome/browser/resources/gaia_auth/util.js
index 72d13c2f2f6..9d8ebd7237d 100644
--- a/chromium/chrome/browser/resources/gaia_auth/util.js
+++ b/chromium/chrome/browser/resources/gaia_auth/util.js
@@ -2,10 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+/**
+ * Alias for document.getElementById.
+ * @param {string} id The ID of the element to find.
+ * @return {HTMLElement} The found element or null if not found.
+ */
function $(id) {
return document.getElementById(id);
}
+/**
+ * Extract query params from given search string of an URL.
+ * @param {string} search The search portion of an URL to extract params.
+ * @return {Object} The key value pairs of the extracted params.
+ */
function getUrlSearchParams(search) {
var params = {};
@@ -51,3 +61,14 @@ function appendParam(url, key, value) {
function stripParams(url) {
return url.substring(0, url.indexOf('?')) || url;
}
+
+/**
+ * Extract domain name from an URL.
+ * @param {string} url An URL string.
+ * @return {string} The host name of the URL.
+ */
+function extractDomain(url) {
+ var a = document.createElement('a');
+ a.href = url;
+ return a.hostname;
+}