| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/dom/URLSearchParams.h" | 5 #include "core/dom/URLSearchParams.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMURL.h" | 7 #include "core/dom/DOMURL.h" |
| 8 #include "platform/network/FormDataEncoder.h" | 8 #include "platform/network/FormDataEncoder.h" |
| 9 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
| 10 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 Vector<std::pair<String, String>> m_params; | 33 Vector<std::pair<String, String>> m_params; |
| 34 size_t m_current; | 34 size_t m_current; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 URLSearchParams* URLSearchParams::create(const URLSearchParamsInit& init) | 39 URLSearchParams* URLSearchParams::create(const URLSearchParamsInit& init) |
| 40 { | 40 { |
| 41 if (init.isUSVString()) | 41 if (init.isUSVString()) { |
| 42 return new URLSearchParams(init.getAsUSVString()); | 42 const String& queryString = init.getAsUSVString(); |
| 43 if (queryString.startsWith('?')) |
| 44 return new URLSearchParams(queryString.substring(1)); |
| 45 return new URLSearchParams(queryString); |
| 46 } |
| 43 if (init.isURLSearchParams()) | 47 if (init.isURLSearchParams()) |
| 44 return new URLSearchParams(init.getAsURLSearchParams()); | 48 return new URLSearchParams(init.getAsURLSearchParams()); |
| 45 | 49 |
| 46 DCHECK(init.isNull()); | 50 DCHECK(init.isNull()); |
| 47 return new URLSearchParams(String()); | 51 return new URLSearchParams(String()); |
| 48 } | 52 } |
| 49 | 53 |
| 50 URLSearchParams::URLSearchParams(const String& queryString, DOMURL* urlObject) | 54 URLSearchParams::URLSearchParams(const String& queryString, DOMURL* urlObject) |
| 51 : m_urlObject(urlObject) | 55 : m_urlObject(urlObject) |
| 52 { | 56 { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FormDataEncoder::addKeyValuePairAsFormData(encodedData, param.first.utf8
(), param.second.utf8(), EncodedFormData::FormURLEncoded); | 219 FormDataEncoder::addKeyValuePairAsFormData(encodedData, param.first.utf8
(), param.second.utf8(), EncodedFormData::FormURLEncoded); |
| 216 return EncodedFormData::create(encodedData.data(), encodedData.size()); | 220 return EncodedFormData::create(encodedData.data(), encodedData.size()); |
| 217 } | 221 } |
| 218 | 222 |
| 219 PairIterable<String, String>::IterationSource* URLSearchParams::startIteration(S
criptState*, ExceptionState&) | 223 PairIterable<String, String>::IterationSource* URLSearchParams::startIteration(S
criptState*, ExceptionState&) |
| 220 { | 224 { |
| 221 return new URLSearchParamsIterationSource(m_params); | 225 return new URLSearchParamsIterationSource(m_params); |
| 222 } | 226 } |
| 223 | 227 |
| 224 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |