Skip to content

Commit

Permalink
FIX: split-path was returning none for these paths: %/, %./ a…
Browse files Browse the repository at this point in the history
…nd `%../`

resolves: Oldes/Rebol-issues#2474
  • Loading branch information
Oldes committed Dec 22, 2021
1 parent 82efc99 commit cf9b34b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mezz/base-files.reb
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ split-path: func [
target [file! url! string!]
/local dir pos
][
parse/all target [
[#"/" | 1 2 #"." opt #"/"] end (dir: dirize target) |
parse target [
[#"/" | 1 2 #"." opt #"/"] end (pos: %"" dir: dirize target) |
pos: any [thru #"/" [end | pos:]] (
all [empty? dir: copy/part target at head target index? pos dir: %./]
all [find [%. %..] pos: to file! pos insert tail pos #"/"]
Expand Down
4 changes: 4 additions & 0 deletions src/tests/units/series-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,10 @@ Rebol [
--assert [%./ %dir] = split-path %dir
--assert [%./ %dir/] = split-path %dir/
--assert [%dir/ %file.txt] = split-path %dir/file.txt
;@@ https://github.com/Oldes/Rebol-issues/issues/2474
--assert [%/ %""] = split-path %/
--assert [%./ %""] = split-path %./
--assert [%../ %""] = split-path %../
--test-- "split-path url!"
--assert [http://foo.net/ %aa.txt] = split-path http://foo.net/aa.txt
--assert [http:// %foo.net/] = split-path http://foo.net/ ;@@ could be better result!
Expand Down

0 comments on commit cf9b34b

Please sign in to comment.