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

Side by Side Diff: url/url_canon_relative.cc

Issue 1409293007: new URL('') should throw TypeError (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated testcase Created 5 years 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 unified diff | Download patch
OLDNEW
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 // Canonicalizer functions for working with and resolving relative URLs. 5 // Canonicalizer functions for working with and resolving relative URLs.
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "url/url_canon.h" 8 #include "url/url_canon.h"
9 #include "url/url_canon_internal.h" 9 #include "url/url_canon_internal.h"
10 #include "url/url_constants.h" 10 #include "url/url_constants.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool is_base_hierarchical, 68 bool is_base_hierarchical,
69 bool* is_relative, 69 bool* is_relative,
70 Component* relative_component) { 70 Component* relative_component) {
71 *is_relative = false; // So we can default later to not relative. 71 *is_relative = false; // So we can default later to not relative.
72 72
73 // Trim whitespace and construct a new range for the substring. 73 // Trim whitespace and construct a new range for the substring.
74 int begin = 0; 74 int begin = 0;
75 TrimURL(url, &begin, &url_len); 75 TrimURL(url, &begin, &url_len);
76 if (begin >= url_len) { 76 if (begin >= url_len) {
77 // Empty URLs are relative, but do nothing. 77 // Empty URLs are relative, but do nothing.
78 if (!is_base_hierarchical) {
79 // Don't allow relative URLs if the base scheme doesn't support it.
80 return false;
81 }
78 *relative_component = Component(begin, 0); 82 *relative_component = Component(begin, 0);
79 *is_relative = true; 83 *is_relative = true;
80 return true; 84 return true;
81 } 85 }
82 86
83 #ifdef WIN32 87 #ifdef WIN32
84 // We special case paths like "C:\foo" so they can link directly to the 88 // We special case paths like "C:\foo" so they can link directly to the
85 // file on Windows (IE compatibility). The security domain stuff should 89 // file on Windows (IE compatibility). The security domain stuff should
86 // prevent a link like this from actually being followed if its on a 90 // prevent a link like this from actually being followed if its on a
87 // web page. 91 // web page.
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 const Component& relative_component, 555 const Component& relative_component,
552 CharsetConverter* query_converter, 556 CharsetConverter* query_converter,
553 CanonOutput* output, 557 CanonOutput* output,
554 Parsed* out_parsed) { 558 Parsed* out_parsed) {
555 return DoResolveRelativeURL<base::char16>( 559 return DoResolveRelativeURL<base::char16>(
556 base_url, base_parsed, base_is_file, relative_url, 560 base_url, base_parsed, base_is_file, relative_url,
557 relative_component, query_converter, output, out_parsed); 561 relative_component, query_converter, output, out_parsed);
558 } 562 }
559 563
560 } // namespace url 564 } // namespace url
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/fast/url/segments-from-data-url-expected.txt ('k') | url/url_canon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698