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: nodejs#11123
Fixes: nodejs#10978
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
watilde authored and italoacasas committed Feb 20, 2017
1 parent b9b7c60 commit 1a70f6c
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 1a70f6c

Please sign in to comment.