From 8f198db2cae0af718a3563bba53f4caf9bc46748 Mon Sep 17 00:00:00 2001 From: Miran Date: Thu, 16 May 2019 21:06:05 +0200 Subject: [PATCH] fixes #10952, UNC paths (#11260) --- lib/pure/pathnorm.nim | 5 ++++- tests/stdlib/tos_unc.nim | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/stdlib/tos_unc.nim diff --git a/lib/pure/pathnorm.nim b/lib/pure/pathnorm.nim index ca869fd037..a067fbbed5 100644 --- a/lib/pure/pathnorm.nim +++ b/lib/pure/pathnorm.nim @@ -28,13 +28,16 @@ proc next*(it: var PathIter; x: string): (int, int) = if not it.notFirst and x[it.i] in {DirSep, AltSep}: # absolute path: inc it.i + when doslikeFileSystem: # UNC paths have leading `\\` + if hasNext(it, x) and x[it.i] == DirSep and + it.i+1 < x.len and x[it.i+1] != DirSep: + inc it.i else: while it.i < x.len and x[it.i] notin {DirSep, AltSep}: inc it.i if it.i > it.prev: result = (it.prev, it.i-1) elif hasNext(it, x): result = next(it, x) - # skip all separators: while it.i < x.len and x[it.i] in {DirSep, AltSep}: inc it.i it.notFirst = true diff --git a/tests/stdlib/tos_unc.nim b/tests/stdlib/tos_unc.nim new file mode 100644 index 0000000000..e55de11cef --- /dev/null +++ b/tests/stdlib/tos_unc.nim @@ -0,0 +1,9 @@ +discard """ + disabled: "posix" +""" + +# bug 10952, UNC paths +import os + +doAssert r"\\hostname\foo\bar" / "baz" == r"\\hostname\foo\bar\baz" +doAssert r"\\?\C:\foo" / "bar" == r"\\?\C:\foo\bar"