Browse Source

url: fix file state clarification in binding

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: https://github.com/nodejs/node/pull/11123
Fixes: https://github.com/nodejs/node/issues/10978
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
v7.x
Daijiro Wachi 8 years ago
committed by Italo A. Casas
parent
commit
72da362d6e
No known key found for this signature in database GPG Key ID: 23EFEFE93C4CFFFE
  1. 8
      src/node_url.cc

8
src/node_url.cc

@ -1074,8 +1074,10 @@ namespace url {
SET_HAVE_QUERY()
url.query = base.query;
}
break;
}
break;
state = kPath;
continue;
case '\\':
case '/':
state = kFileSlash;
@ -1092,8 +1094,8 @@ namespace url {
}
SET_HAVE_QUERY()
state = kQuery;
break;
}
break;
case '#':
if (base_is_file) {
if (DOES_HAVE_HOST(base)) {
@ -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]) ||

Loading…
Cancel
Save