Skip to content

Commit

Permalink
url: fix file state clarification in binding
Browse files Browse the repository at this point in the history
An empty file URL `file:` should be parsed to `file:///` instead of
`file://`. In the `kFile` state, the process was braked immediately
when the ch is EOL, but it should work as `default` in the kFile state
to adjust slashes.

Applicable cases:
* `file:#foo` => `file:///#foo`
* `file:?bar` => `file:///?bar`

PR-URL: #11123
Fixes: #10978
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
watilde authored and italoacasas committed Feb 22, 2017
1 parent 12cf359 commit 72da362
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,10 @@ namespace url {
SET_HAVE_QUERY()
url.query = base.query;
}
break;
}
break;
state = kPath;
continue;
case '\\':
case '/':
state = kFileSlash;
Expand All @@ -1092,8 +1094,8 @@ namespace url {
}
SET_HAVE_QUERY()
state = kQuery;
break;
}
break;
case '#':
if (base_is_file) {
if (DOES_HAVE_HOST(base)) {
Expand All @@ -1109,8 +1111,8 @@ namespace url {
url.query = base.query;
}
state = kFragment;
break;
}
break;
default:
if (base_is_file &&
(!WINDOWS_DRIVE_LETTER(ch, p[1]) ||
Expand Down

0 comments on commit 72da362

Please sign in to comment.