Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // Miscellaneous utility functions for HTML media tests. Loading this script | |
| 6 // should not modify the page in any way. | |
| 7 // | |
| 8 | |
| 9 var QueryString = function () { | |
|
shadi
2012/01/25 19:30:04
I am not sure why we need this function? Can't we
DaleCurtis
2012/01/25 23:59:25
We could, in this case though this test will be go
| |
| 10 // Allows access to query parameters on the URL; e.g., given a URL like: | |
| 11 // | |
| 12 // http://<url>/my.html?test=123&bob=123 | |
| 13 // | |
| 14 // parameters can now be accessed via QueryString.test or QueryString.bob. | |
| 15 var params = {}; | |
| 16 | |
| 17 // RegEx to split out values by &. | |
| 18 var r = /([^&=]+)=?([^&]*)/g; | |
| 19 | |
| 20 // Lambda function for decoding extracted match values. Replaces '+' with | |
| 21 // space so decodeURIComponent functions properly. | |
| 22 var d = function (s) { return decodeURIComponent(s.replace(/\+/g, ' ')); } | |
|
Ami GONE FROM CHROMIUM
2012/01/25 17:58:48
Why var and not just
function d(s) {...}
?
DaleCurtis
2012/01/25 23:59:25
Done.
| |
| 23 | |
| 24 var match; | |
| 25 while (match = r.exec(window.location.search.substring(1))) | |
| 26 params[d(match[1])] = d(match[2]); | |
| 27 | |
| 28 return params; | |
| 29 } (); | |
|
shadi
2012/01/25 19:30:04
Does this directly call the QueryString function w
DaleCurtis
2012/01/25 23:59:25
Yes.
| |
| OLD | NEW |