OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_HISTORY_URL_UTILS_H_ | |
6 #define CHROME_BROWSER_HISTORY_URL_UTILS_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "chrome/browser/history/history_types.h" | |
11 | |
12 namespace history { | |
13 | |
14 // CanonicalURLStringCompare performs lexicographical comparison of two strings | |
15 // that represent valid URLs, so that if the pre-path (scheme, host, and port) | |
16 // parts are equal, then the path parts are compared by treating path components | |
17 // (deliminted by "/") as separate tokens that form units of comparison. | |
sky
2013/09/12 23:51:41
delimited
huangs
2013/09/13 02:30:37
Done.
| |
18 // For example, let us compare |s1| and |s2|, with | |
19 // |s1| = "http://www.google.com:80/base/test/ab/cd?query/stuff" | |
20 // |s2| = "http://www.google.com:80/base/test-case/yz#ref/stuff" | |
21 // The pre-path parts "http://www.google.com:80/" match, so we the path is | |
22 // treated as | |
23 // |s1| => ["base", "test", "ab", "cd"] | |
24 // |s2| => ["base", "test-case", "yz"] | |
25 // Component 1 "base" matches. Component 2 produces "test" < "test-case", thus | |
26 // resulting in |s1| < |s2|, and we return true. Note that naive string | |
27 // comparison would yield the opposite (|s1| > |s2|), since '/' > '-' in ASCII. | |
28 // Note that path is terminated by "?query" or "#ref". The post-path parts | |
29 // are compared in an arbitrary (but consistent) way. | |
30 bool CanonicalURLStringCompare(const std::string& s1, const std::string& s2); | |
31 | |
32 // Returns whether or not |url1| is a "URL prefix" of |url2|. Criteria: | |
33 // - Scheme, host, port: exact match required. | |
34 // - Path: treated as a list of path components (e.g., ["a", "bb"] for "/a/bb"), | |
35 // and |url1|'s list must be a prefix of |url2|'s list. | |
36 // - Query and ref: ignored. | |
37 // Note that "http://www.google.com/test" is NOT a prefix of | |
38 // "http://www.google.com/testing", although "test" is a prefix of "testing". | |
39 bool UrlIsPrefix(const GURL& url1, const GURL& url2); | |
40 | |
41 } // namespace history | |
42 | |
43 #endif // CHROME_BROWSER_HISTORY_URL_UTILS_H_ | |
OLD | NEW |