Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @fileoverview Common methods for performance-plotting Javascript. | 8 * @fileoverview Common methods for performance-plotting Javascript. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Creates the URL constructed from the current pathname and the given params. | 74 * Creates the URL constructed from the current pathname and the given params. |
| 75 * | 75 * |
| 76 * @param {Object} An object containing parameters for a URL query string. | 76 * @param {Object} An object containing parameters for a URL query string. |
| 77 * @return {string} The URL constructed from the given params. | 77 * @return {string} The URL constructed from the given params. |
| 78 */ | 78 */ |
| 79 function MakeURL(params) { | 79 function MakeURL(params) { |
| 80 var url = window.location.pathname; | 80 var arr = []; |
| 81 var sep = '?'; | 81 for (var p in params) { |
| 82 for (p in params) { | 82 if (typeof params[p] == 'object') { |
| 83 if (!p) | 83 // Repeated params, stored as hash like {valueA: 1, valueB: 1} |
| 84 continue; | 84 for (var r in params[p]) { |
| 85 url += sep + p + '=' + params[p]; | 85 arr.push(p + '=' + r); |
|
alias of yukishiino
2012/11/02 04:19:19
I'm not sure if it's necessary to check the value
alias of yukishiino
2012/11/02 04:19:19
You should call encodeURIComponent for each value.
| |
| 86 sep = '&'; | 86 } |
| 87 } else { | |
| 88 arr.push(p + '=' + params[p]); | |
| 89 } | |
| 87 } | 90 } |
| 88 return url; | 91 return window.location.pathname + '?' + arr.join('&'); |
| 89 } | 92 } |
| OLD | NEW |