Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "net/base/url_util.h" | 5 #include "net/base/url_util.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 std::string param_value = EscapeQueryParamValue(value, true); | 36 std::string param_value = EscapeQueryParamValue(value, true); |
| 37 | 37 |
| 38 const std::string input = url.query(); | 38 const std::string input = url.query(); |
| 39 url::Component cursor(0, input.size()); | 39 url::Component cursor(0, input.size()); |
| 40 std::string output; | 40 std::string output; |
| 41 url::Component key_range, value_range; | 41 url::Component key_range, value_range; |
| 42 while (url::ExtractQueryKeyValue(input.data(), &cursor, &key_range, | 42 while (url::ExtractQueryKeyValue(input.data(), &cursor, &key_range, |
| 43 &value_range)) { | 43 &value_range)) { |
| 44 const base::StringPiece key( | 44 const base::StringPiece key( |
| 45 input.data() + key_range.begin, key_range.len); | 45 input.data() + key_range.begin, key_range.len); |
| 46 const base::StringPiece value( | |
| 47 input.data() + value_range.begin, value_range.len); | |
|
scottmg
2015/02/20 05:02:06
this one seems a little tricky because it's shadow
| |
| 48 std::string key_value_pair; | 46 std::string key_value_pair; |
| 49 // Check |replaced| as only the first pair should be replaced. | 47 // Check |replaced| as only the first pair should be replaced. |
| 50 if (!replaced && key == param_name) { | 48 if (!replaced && key == param_name) { |
| 51 replaced = true; | 49 replaced = true; |
| 52 key_value_pair = (param_name + "=" + param_value); | 50 key_value_pair = (param_name + "=" + param_value); |
| 53 } else { | 51 } else { |
| 54 key_value_pair.assign(input.data(), | 52 key_value_pair.assign(input.data(), |
| 55 key_range.begin, | 53 key_range.begin, |
| 56 value_range.end() - key_range.begin); | 54 value_range.end() - key_range.begin); |
| 57 } | 55 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 for (QueryIterator it(url); !it.IsAtEnd(); it.Advance()) { | 126 for (QueryIterator it(url); !it.IsAtEnd(); it.Advance()) { |
| 129 if (it.GetKey() == search_key) { | 127 if (it.GetKey() == search_key) { |
| 130 *out_value = it.GetUnescapedValue(); | 128 *out_value = it.GetUnescapedValue(); |
| 131 return true; | 129 return true; |
| 132 } | 130 } |
| 133 } | 131 } |
| 134 return false; | 132 return false; |
| 135 } | 133 } |
| 136 | 134 |
| 137 } // namespace net | 135 } // namespace net |
| OLD | NEW |