From bc4a925797b7e6f2e730297ec6bfffa7ef4112e3 Mon Sep 17 00:00:00 2001 From: Antony Date: Mon, 8 Jan 2018 12:23:56 +0300 Subject: [PATCH] Windows local file path resolve fix --- src/url.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/url.cpp b/src/url.cpp index 1f54327..408356c 100644 --- a/src/url.cpp +++ b/src/url.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -266,6 +267,15 @@ namespace Url } } + // Windows file path + if ((strncmp(scheme_.c_str(), "file", 4) == 0) && + (static_cast(url.length() - position) >= 2 + && url[position] == '/' + && url[position + 2] == ':')) + { + position += 1; + } + if (position != std::string::npos) { path_.assign(url, position, std::string::npos); @@ -443,7 +453,8 @@ namespace Url } else { - if (!host_.empty() && path_[0] != '/') + if ((!host_.empty() && path_[0] != '/') || + (host_.empty() && path_[0] != '/' && path_[1] == ':')) { result.append(1, '/'); }