OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Motorola Mobility Inc. | 3 * Copyright (C) 2012 Motorola Mobility Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 return; | 114 return; |
115 kurl.setPath(value); | 115 kurl.setPath(value); |
116 setURL(kurl); | 116 setURL(kurl); |
117 } | 117 } |
118 | 118 |
119 void DOMURLUtils::setSearch(const String& value) | 119 void DOMURLUtils::setSearch(const String& value) |
120 { | 120 { |
121 KURL kurl = url(); | 121 KURL kurl = url(); |
122 if (!kurl.isValid()) | 122 if (!kurl.isValid()) |
123 return; | 123 return; |
124 kurl.setQuery(value); | 124 |
125 if (value[0] == '?') | |
arv (Not doing code reviews)
2014/09/03 22:08:36
Do we need to handle length 0 before this test?
sof
2014/09/04 06:52:24
No real need, [] returns 0 over out-of-bounds indi
| |
126 kurl.setQuery(value.length() == 1 ? String() : value.substring(1)); | |
arv (Not doing code reviews)
2014/09/03 22:08:36
I thought KURL::setQuery did this?
https://code.g
sof
2014/09/04 06:52:24
That handling strips the leading '?', but doesn't
| |
127 else | |
128 kurl.setQuery(value.isEmpty() ? String() : value); | |
129 | |
125 setURL(kurl); | 130 setURL(kurl); |
126 } | 131 } |
127 | 132 |
128 void DOMURLUtils::setHash(const String& value) | 133 void DOMURLUtils::setHash(const String& value) |
129 { | 134 { |
130 KURL kurl = url(); | 135 KURL kurl = url(); |
131 if (kurl.isNull()) | 136 if (kurl.isNull()) |
132 return; | 137 return; |
133 | 138 |
134 if (value[0] == '#') | 139 if (value[0] == '#') |
135 kurl.setFragmentIdentifier(value.substring(1)); | 140 kurl.setFragmentIdentifier(value.length() == 1 ? String() : value.substr ing(1)); |
136 else | 141 else |
137 kurl.setFragmentIdentifier(value); | 142 kurl.setFragmentIdentifier(value.isEmpty() ? String() : value); |
138 | 143 |
139 setURL(kurl); | 144 setURL(kurl); |
140 } | 145 } |
141 | 146 |
142 } // namespace blink | 147 } // namespace blink |
OLD | NEW |