Skip to content

Commit 974dced

Browse files
committed
Windows local file path resolve fix
1 parent e884eac commit 974dced

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/url.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ namespace Url
266266
}
267267
}
268268

269+
// Windows file path
270+
if ((strncmp(scheme_.c_str(), "file", 4) == 0) &&
271+
(static_cast<int>(url.length() - position) >= 2
272+
&& url[position] == '/'
273+
&& url[position + 2] == ':'))
274+
{
275+
position += 1;
276+
}
277+
269278
if (position != std::string::npos)
270279
{
271280
path_.assign(url, position, std::string::npos);
@@ -443,7 +452,8 @@ namespace Url
443452
}
444453
else
445454
{
446-
if (!host_.empty() && path_[0] != '/')
455+
if ((!host_.empty() && path_[0] != '/') ||
456+
(host_.empty() && path_[0] != '/' && path_[1] == ':'))
447457
{
448458
result.append(1, '/');
449459
}

0 commit comments

Comments
 (0)