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]) || diff --git a/test/fixtures/url-tests.json b/test/fixtures/url-tests.json index 634a8e3f663985..fb286ed91fcbd7 100644 --- a/test/fixtures/url-tests.json +++ b/test/fixtures/url-tests.json @@ -4649,5 +4649,119 @@ "pathname": "/", "search": "", "hash": "" + }, + "# More file URL tests by zcorpan", + { + "input": "/", + "base": "file:///C:/a/b", + "href": "file:///C:/", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/", + "search": "", + "hash": "" + }, + { + "input": "//d:", + "base": "file:///C:/a/b", + "href": "file:///d:", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/d:", + "search": "", + "hash": "" + }, + { + "input": "//d:/..", + "base": "file:///C:/a/b", + "href": "file:///d:/", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/d:/", + "search": "", + "hash": "" + }, + { + "input": "..", + "base": "file:///ab:/", + "href": "file:///", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/", + "search": "", + "hash": "" + }, + { + "input": "..", + "base": "file:///1:/", + "href": "file:///", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/", + "search": "", + "hash": "" + }, + "# file URLs without base URL by Rimas Misevičius", + { + "input": "file:", + "base": "about:blank", + "href": "file:///", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/", + "search": "", + "hash": "" + }, + { + "input": "file:?q=v", + "base": "about:blank", + "href": "file:///?q=v", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/", + "search": "?q=v", + "hash": "" + }, + { + "input": "file:#frag", + "base": "about:blank", + "href": "file:///#frag", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/", + "search": "", + "hash": "#frag" } ]