summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaijiro Wachi <daijiro.wachi@gmail.com>2017-04-10 18:09:06 +0200
committerDaijiro Wachi <daijiro.wachi@gmail.com>2017-04-10 18:09:06 +0200
commitb470a85f071ccdde0e24b48a6fe8389b0a54750d (patch)
tree6a8577469a5a7c61d3248985df879ffb10559d4d /src
parent88351a22eda7c2d3371a1faaaa30ab846ce77f52 (diff)
downloadandroid-node-v8-b470a85f071ccdde0e24b48a6fe8389b0a54750d.tar.gz
android-node-v8-b470a85f071ccdde0e24b48a6fe8389b0a54750d.tar.bz2
android-node-v8-b470a85f071ccdde0e24b48a6fe8389b0a54750d.zip
url: trim leading slashes of file URL paths
It should trim the slashes after the colon into three for file URL. PR-URL: https://github.com/nodejs/node/pull/12203 Refs: https://github.com/w3c/web-platform-tests/pull/5195 Fixes: https://github.com/nodejs/node/issues/11188 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_url.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index f9965d537b..16a4cdd45b 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -1108,12 +1108,14 @@ namespace url {
state = kFileHost;
} else {
if (has_base &&
- base->scheme == "file:" &&
- base->flags & URL_FLAGS_HAS_PATH &&
- base->path.size() > 0 &&
- NORMALIZED_WINDOWS_DRIVE_LETTER(base->path[0])) {
- url->flags |= URL_FLAGS_HAS_PATH;
- url->path.push_back(base->path[0]);
+ base->scheme == "file:") {
+ if (NORMALIZED_WINDOWS_DRIVE_LETTER(base->path[0])) {
+ url->flags |= URL_FLAGS_HAS_PATH;
+ url->path.push_back(base->path[0]);
+ } else {
+ url->flags |= URL_FLAGS_HAS_HOST;
+ url->host = base->host;
+ }
}
state = kPath;
continue;
@@ -1196,6 +1198,14 @@ namespace url {
url->path.push_back(segment);
}
buffer.clear();
+ if (url->scheme == "file:" &&
+ (ch == kEOL ||
+ ch == '?' ||
+ ch == '#')) {
+ while (url->path.size() > 1 && url->path[0].length() == 0) {
+ url->path.erase(url->path.begin());
+ }
+ }
if (ch == '?') {
url->flags |= URL_FLAGS_HAS_QUERY;
state = kQuery;