OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Alias for document.getElementById. | 6 * Alias for document.getElementById. |
7 * @param {string} id The ID of the element to find. | 7 * @param {string} id The ID of the element to find. |
8 * @return {HTMLElement} The found element or null if not found. | 8 * @return {HTMLElement} The found element or null if not found. |
9 */ | 9 */ |
10 function $(id) { | 10 function $(id) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 /** | 65 /** |
66 * Extract domain name from an URL. | 66 * Extract domain name from an URL. |
67 * @param {string} url An URL string. | 67 * @param {string} url An URL string. |
68 * @return {string} The host name of the URL. | 68 * @return {string} The host name of the URL. |
69 */ | 69 */ |
70 function extractDomain(url) { | 70 function extractDomain(url) { |
71 var a = document.createElement('a'); | 71 var a = document.createElement('a'); |
72 a.href = url; | 72 a.href = url; |
73 return a.hostname; | 73 return a.hostname; |
74 } | 74 } |
| 75 |
| 76 /** |
| 77 * Extract protocol from an URL. |
| 78 * @param {string} url An URL string. |
| 79 * @return {string} The protocol of the URL. |
| 80 */ |
| 81 function extractProtocol(url) { |
| 82 var a = document.createElement('a'); |
| 83 a.href = url; |
| 84 return a.protocol; |
| 85 } |
| 86 |
OLD | NEW |