@@ -1904,16 +1904,19 @@ void URL::Parse(const char* input,
1904
1904
state = kFragment ;
1905
1905
break ;
1906
1906
default :
1907
+ url->query .clear ();
1908
+ if (base->flags & URL_FLAGS_HAS_HOST) {
1909
+ url->flags |= URL_FLAGS_HAS_HOST;
1910
+ url->host = base->host ;
1911
+ }
1912
+ if (base->flags & URL_FLAGS_HAS_PATH) {
1913
+ url->flags |= URL_FLAGS_HAS_PATH;
1914
+ url->path = base->path ;
1915
+ }
1907
1916
if (!StartsWithWindowsDriveLetter (p, end)) {
1908
- if (base->flags & URL_FLAGS_HAS_HOST) {
1909
- url->flags |= URL_FLAGS_HAS_HOST;
1910
- url->host = base->host ;
1911
- }
1912
- if (base->flags & URL_FLAGS_HAS_PATH) {
1913
- url->flags |= URL_FLAGS_HAS_PATH;
1914
- url->path = base->path ;
1915
- }
1916
1917
ShortenUrlPath (url);
1918
+ } else {
1919
+ url->path .clear ();
1917
1920
}
1918
1921
state = kPath ;
1919
1922
continue ;
@@ -1927,20 +1930,13 @@ void URL::Parse(const char* input,
1927
1930
if (ch == ' /' || ch == ' \\ ' ) {
1928
1931
state = kFileHost ;
1929
1932
} else {
1930
- if (has_base &&
1931
- base->scheme == " file:" &&
1932
- !StartsWithWindowsDriveLetter (p, end)) {
1933
- if (IsNormalizedWindowsDriveLetter (base->path [0 ])) {
1933
+ if (has_base && base->scheme == " file:" ) {
1934
+ url->flags |= URL_FLAGS_HAS_HOST;
1935
+ url->host = base->host ;
1936
+ if (!StartsWithWindowsDriveLetter (p, end) &&
1937
+ IsNormalizedWindowsDriveLetter (base->path [0 ])) {
1934
1938
url->flags |= URL_FLAGS_HAS_PATH;
1935
1939
url->path .push_back (base->path [0 ]);
1936
- } else {
1937
- if (base->flags & URL_FLAGS_HAS_HOST) {
1938
- url->flags |= URL_FLAGS_HAS_HOST;
1939
- url->host = base->host ;
1940
- } else {
1941
- url->flags &= ~URL_FLAGS_HAS_HOST;
1942
- url->host .clear ();
1943
- }
1944
1940
}
1945
1941
}
1946
1942
state = kPath ;
@@ -2024,29 +2020,19 @@ void URL::Parse(const char* input,
2024
2020
url->path .empty () &&
2025
2021
buffer.size () == 2 &&
2026
2022
IsWindowsDriveLetter (buffer)) {
2027
- if ((url->flags & URL_FLAGS_HAS_HOST) &&
2028
- !url->host .empty ()) {
2029
- url->host .clear ();
2030
- url->flags |= URL_FLAGS_HAS_HOST;
2031
- }
2032
2023
buffer[1 ] = ' :' ;
2033
2024
}
2034
2025
url->flags |= URL_FLAGS_HAS_PATH;
2035
2026
url->path .emplace_back (std::move (buffer));
2036
2027
}
2037
2028
buffer.clear ();
2038
- if (url->scheme == " file:" &&
2039
- (ch == kEOL ||
2040
- ch == ' ?' ||
2041
- ch == ' #' )) {
2042
- while (url->path .size () > 1 && url->path [0 ].empty ()) {
2043
- url->path .erase (url->path .begin ());
2044
- }
2045
- }
2046
2029
if (ch == ' ?' ) {
2047
2030
url->flags |= URL_FLAGS_HAS_QUERY;
2031
+ url->query .clear ();
2048
2032
state = kQuery ;
2049
2033
} else if (ch == ' #' ) {
2034
+ url->flags |= URL_FLAGS_HAS_FRAGMENT;
2035
+ url->fragment .clear ();
2050
2036
state = kFragment ;
2051
2037
}
2052
2038
} else {
0 commit comments