Permalink
Browse files

path, bugfix: keep the disk no of the last path.

  • Loading branch information...
xicilion committed Nov 7, 2017
1 parent ddd6eaa commit 402f7727d1f10dee2b9f9f1f7fa4a4d27ff1d9a7
Showing with 10 additions and 3 deletions.
  1. +4 −3 fibjs/include/path.h
  2. +6 −0 test/path_test.js
View
@@ -47,6 +47,7 @@ class Path {
if (qisascii(c_str[0]) && c_str[1] == ':') {
diskId = c_str[0];
m_buf = m_disks[diskId & 0x1f];
m_buf[0] = c_str[0];
c_str += 2;
}
@@ -158,7 +159,7 @@ inline const char* split_path(const char* p)
const char* p1 = p;
const char* p2 = NULL;
if (p[0] != 0 && p[1] == ':') {
if (qisascii(p[0]) && p[1] == ':') {
p += 2;
if (isPosixPathSlash(*p))
p++;
@@ -202,7 +203,7 @@ inline const char* split_path_win32(const char* p)
const char* p1 = p;
const char* p2 = NULL;
if (p[0] != 0 && p[1] == ':') {
if (qisascii(p[0]) && p[1] == ':') {
p += 2;
if (isWin32PathSlash(*p))
p++;
@@ -334,7 +335,7 @@ inline result_t _normalize_win32(exlib::string path, exlib::string& retVal, bool
exlib::string domain;
exlib::string share;
if (p[0] != 0 && p[1] == ':') {
if (qisascii(p[0]) && p[1] == ':') {
drv_no = p[0];
p += 2;
len -= 2;
View
@@ -586,6 +586,12 @@ describe('path', () => {
// [
// ['c:/', '//dir'], 'c:\\dir'
// ],
[
['c:/', 'C://'], 'C:\\'
],
[
['C:/', 'c://'], 'c:\\'
],
[
['', '//server/share'], '\\\\server\\share\\'
],

0 comments on commit 402f772

Please sign in to comment.