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

Side by Side Diff: url/url_parse_internal.h

Issue 23835019: Support URL fragment resolution againt non-hierarchical schemes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: brettw2 Created 7 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 | Annotate | Revision Log
« no previous file with comments | « url/url_canon_unittest.cc ('k') | url/url_parse_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef URL_URL_PARSE_INTERNAL_H_ 5 #ifndef URL_URL_PARSE_INTERNAL_H_
6 #define URL_URL_PARSE_INTERNAL_H_ 6 #define URL_URL_PARSE_INTERNAL_H_
7 7
8 // Contains common inline helper functions used by the URL parsing routines. 8 // Contains common inline helper functions used by the URL parsing routines.
9 9
10 #include "url/url_parse.h" 10 #include "url/url_parse.h"
(...skipping 10 matching lines...) Expand all
21 inline bool ShouldTrimFromURL(base::char16 ch) { 21 inline bool ShouldTrimFromURL(base::char16 ch) {
22 return ch <= ' '; 22 return ch <= ' ';
23 } 23 }
24 24
25 // Given an already-initialized begin index and length, this shrinks the range 25 // Given an already-initialized begin index and length, this shrinks the range
26 // to eliminate "should-be-trimmed" characters. Note that the length does *not* 26 // to eliminate "should-be-trimmed" characters. Note that the length does *not*
27 // indicate the length of untrimmed data from |*begin|, but rather the position 27 // indicate the length of untrimmed data from |*begin|, but rather the position
28 // in the input string (so the string starts at character |*begin| in the spec, 28 // in the input string (so the string starts at character |*begin| in the spec,
29 // and goes until |*len|). 29 // and goes until |*len|).
30 template<typename CHAR> 30 template<typename CHAR>
31 inline void TrimURL(const CHAR* spec, int* begin, int* len) { 31 inline void TrimURL(const CHAR* spec, int* begin, int* len,
32 bool trim_path_end = true) {
32 // Strip leading whitespace and control characters. 33 // Strip leading whitespace and control characters.
33 while (*begin < *len && ShouldTrimFromURL(spec[*begin])) 34 while (*begin < *len && ShouldTrimFromURL(spec[*begin]))
34 (*begin)++; 35 (*begin)++;
35 36
36 // Strip trailing whitespace and control characters. We need the >i test for 37 if (trim_path_end) {
37 // when the input string is all blanks; we don't want to back past the input. 38 // Strip trailing whitespace and control characters. We need the >i test
38 while (*len > *begin && ShouldTrimFromURL(spec[*len - 1])) 39 // for when the input string is all blanks; we don't want to back past the
39 (*len)--; 40 // input.
41 while (*len > *begin && ShouldTrimFromURL(spec[*len - 1]))
42 (*len)--;
43 }
40 } 44 }
41 45
42 // Counts the number of consecutive slashes starting at the given offset 46 // Counts the number of consecutive slashes starting at the given offset
43 // in the given string of the given length. 47 // in the given string of the given length.
44 template<typename CHAR> 48 template<typename CHAR>
45 inline int CountConsecutiveSlashes(const CHAR *str, 49 inline int CountConsecutiveSlashes(const CHAR *str,
46 int begin_offset, int str_len) { 50 int begin_offset, int str_len) {
47 int count = 0; 51 int count = 0;
48 while (begin_offset + count < str_len && 52 while (begin_offset + count < str_len &&
49 IsURLSlash(str[begin_offset + count])) 53 IsURLSlash(str[begin_offset + count]))
(...skipping 28 matching lines...) Expand all
78 int after_scheme, 82 int after_scheme,
79 Parsed* parsed); 83 Parsed* parsed);
80 void ParseAfterScheme(const base::char16* spec, 84 void ParseAfterScheme(const base::char16* spec,
81 int spec_len, 85 int spec_len,
82 int after_scheme, 86 int after_scheme,
83 Parsed* parsed); 87 Parsed* parsed);
84 88
85 } // namespace url_parse 89 } // namespace url_parse
86 90
87 #endif // URL_URL_PARSE_INTERNAL_H_ 91 #endif // URL_URL_PARSE_INTERNAL_H_
OLDNEW
« no previous file with comments | « url/url_canon_unittest.cc ('k') | url/url_parse_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698