From 72da362d6e7dbdbd0d314d8ebf68ea6eeca26271 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Tue, 7 Feb 2017 18:45:27 +0100 Subject: [PATCH] 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 Reviewed-By: Joyee Cheung --- src/node_url.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/node_url.cc b/src/node_url.cc index 0d5e695a3c13a5..5027399e89dd71 100644 --- a/src/node_url.cc +++ b/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]) ||