Skip to content

Commit 9b342a9

Browse files
committed
root: dedupe logic
1 parent 3ed99d9 commit 9b342a9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

+stdlib/root.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
else
1010

1111
r = "";
12+
if ~stdlib.is_absolute(p)
13+
return
14+
end
1215

13-
if startsWith(p, "/")
14-
r = "/";
15-
elseif ispc && strlength(p) >= 2 && isletter(extractBetween(p, 1, 1)) && extractBetween(p, 2, 2) == ":"
16+
if ispc
1617
r = extractBetween(p, 1, 2) + "/";
18+
else
19+
r = "/";
1720
end
1821

1922
end

test/TestFilePure.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
ref_proximate_to = ref_relative_to;
5656
ref_proximate_to{end} = other_relative_to{end};
5757

58-
ref_root{end} = "c:/";
58+
ref_root{5} = "";
59+
ref_root{6} = "c:/";
5960

6061
else
6162

0 commit comments

Comments
 (0)