@@ -1904,16 +1904,19 @@ void URL::Parse(const char* input,
19041904 state = kFragment ;
19051905 break ;
19061906 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+ }
19071916 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- }
19161917 ShortenUrlPath (url);
1918+ } else {
1919+ url->path .clear ();
19171920 }
19181921 state = kPath ;
19191922 continue ;
@@ -1927,20 +1930,13 @@ void URL::Parse(const char* input,
19271930 if (ch == ' /' || ch == ' \\ ' ) {
19281931 state = kFileHost ;
19291932 } 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 ])) {
19341938 url->flags |= URL_FLAGS_HAS_PATH;
19351939 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- }
19441940 }
19451941 }
19461942 state = kPath ;
@@ -2024,29 +2020,19 @@ void URL::Parse(const char* input,
20242020 url->path .empty () &&
20252021 buffer.size () == 2 &&
20262022 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- }
20322023 buffer[1 ] = ' :' ;
20332024 }
20342025 url->flags |= URL_FLAGS_HAS_PATH;
20352026 url->path .emplace_back (std::move (buffer));
20362027 }
20372028 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- }
20462029 if (ch == ' ?' ) {
20472030 url->flags |= URL_FLAGS_HAS_QUERY;
2031+ url->query .clear ();
20482032 state = kQuery ;
20492033 } else if (ch == ' #' ) {
2034+ url->flags |= URL_FLAGS_HAS_FRAGMENT;
2035+ url->fragment .clear ();
20502036 state = kFragment ;
20512037 }
20522038 } else {
0 commit comments