Skip to content

Commit cf9b34b

Browse files
committed
FIX: split-path was returning none for these paths: %/, %./ and %../
resolves: Oldes/Rebol-issues#2474
1 parent 82efc99 commit cf9b34b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/mezz/base-files.reb

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ split-path: func [
161161
target [file! url! string!]
162162
/local dir pos
163163
][
164-
parse/all target [
165-
[#"/" | 1 2 #"." opt #"/"] end (dir: dirize target) |
164+
parse target [
165+
[#"/" | 1 2 #"." opt #"/"] end (pos: %"" dir: dirize target) |
166166
pos: any [thru #"/" [end | pos:]] (
167167
all [empty? dir: copy/part target at head target index? pos dir: %./]
168168
all [find [%. %..] pos: to file! pos insert tail pos #"/"]

src/tests/units/series-test.r3

+4
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,10 @@ Rebol [
18911891
--assert [%./ %dir] = split-path %dir
18921892
--assert [%./ %dir/] = split-path %dir/
18931893
--assert [%dir/ %file.txt] = split-path %dir/file.txt
1894+
;@@ https://github.com/Oldes/Rebol-issues/issues/2474
1895+
--assert [%/ %""] = split-path %/
1896+
--assert [%./ %""] = split-path %./
1897+
--assert [%../ %""] = split-path %../
18941898
--test-- "split-path url!"
18951899
--assert [http://foo.net/ %aa.txt] = split-path http://foo.net/aa.txt
18961900
--assert [http:// %foo.net/] = split-path http://foo.net/ ;@@ could be better result!

0 commit comments

Comments
 (0)