@@ -465,35 +465,30 @@ auto url_parser_context::parse_port(char byte) -> tl::expected<url_parse_action,
465465
466466auto url_parser_context::parse_file (char byte) -> tl::expected<url_parse_action, url_parse_errc> {
467467 url.scheme = " file" ;
468+ url.host = host{empty_host{}};
468469
469470 if ((byte == ' /' ) || (byte == ' \\ ' )) {
470471 if (byte == ' \\ ' ) {
471472 *validation_error |= true ;
472473 }
473474 state = url_parse_state::file_slash;
474475 } else if (base && (base->scheme == " file" )) {
475- if (is_eof ()) {
476- url.host = base->host ;
477- url.path = base->path ;
478- url.query = base->query ;
479- } else if (byte == ' ?' ) {
480- url.host = base->host ;
481- url.path = base->path ;
476+ url.host = base->host ;
477+ url.path = base->path ;
478+ url.query = base->query ;
479+ if (byte == ' ?' ) {
482480 url.query = std::string ();
483481 state = url_parse_state::query;
484482 } else if (byte == ' #' ) {
485- url.host = base->host ;
486- url.path = base->path ;
487- url.query = base->query ;
488483 url.fragment = std::string ();
489484 state = url_parse_state::fragment;
490485 } else {
486+ url.query = std::nullopt ;
491487 if (!is_windows_drive_letter (input.substr (std::distance (begin (input), it)))) {
492- url.host = base->host ;
493- url.path = base->path ;
494488 shorten_path (url.scheme , url.path );
495489 } else {
496490 *validation_error |= true ;
491+ url.path .clear ();
497492 }
498493 state = url_parse_state::path;
499494 if (it == begin (input)) {
@@ -519,10 +514,11 @@ auto url_parser_context::parse_file_slash(char byte) -> tl::expected<url_parse_a
519514 }
520515 state = url_parse_state::file_host;
521516 } else {
522- auto substr = input.substr (std::distance (begin (input), it));
523- if (base && ((base->scheme == " file" ) && !is_windows_drive_letter (substr))) {
524- if (!base->path .empty () && is_windows_drive_letter (base->path [0 ])) {
525- url.path .push_back (base->path [0 ]);
517+ if (base && (base->scheme == " file" )) {
518+ auto substr = input.substr (std::distance (begin (input), it));
519+ if (!is_windows_drive_letter (substr) &&
520+ (!base->path .empty () && is_windows_drive_letter (base->path [0 ]))) {
521+ url.path .push_back (base->path [0 ]);
526522 } else {
527523 url.host = base->host ;
528524 }
0 commit comments