Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: Source/core/dom/DOMURLUtils.cpp

Issue 537103002: Spec compliant url.search/url.hash setters over empty values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Sync expected output Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/win/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DOMURLUtils.cpp
diff --git a/Source/core/dom/DOMURLUtils.cpp b/Source/core/dom/DOMURLUtils.cpp
index a3940bb17a5eedd78cfd3d168fbf4fccb1bab973..361b37affde7ae12925e835d4f6dfdf3cea26609 100644
--- a/Source/core/dom/DOMURLUtils.cpp
+++ b/Source/core/dom/DOMURLUtils.cpp
@@ -121,7 +121,15 @@ void DOMURLUtils::setSearch(const String& value)
KURL kurl = url();
if (!kurl.isValid())
return;
- kurl.setQuery(value);
+
+ // FIXME: have KURL do this clearing of the query component
+ // instead, if practical. Will require addressing
+ // http://crbug.com/108690, for one.
+ if (value[0] == '?')
+ kurl.setQuery(value.length() == 1 ? String() : value.substring(1));
+ else
+ kurl.setQuery(value.isEmpty() ? String() : value);
+
setURL(kurl);
}
@@ -131,10 +139,12 @@ void DOMURLUtils::setHash(const String& value)
if (kurl.isNull())
return;
+ // FIXME: have KURL handle the clearing of the fragment component
+ // on the same input.
if (value[0] == '#')
- kurl.setFragmentIdentifier(value.substring(1));
+ kurl.setFragmentIdentifier(value.length() == 1 ? String() : value.substring(1));
else
- kurl.setFragmentIdentifier(value);
+ kurl.setFragmentIdentifier(value.isEmpty() ? String() : value);
setURL(kurl);
}
« no previous file with comments | « LayoutTests/platform/win/fast/dom/HTMLAnchorElement/set-href-attribute-search-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698