Skip to content

Commit 55431f5

Browse files
committed
relative, proximate: empty output for both inputs empty
1 parent a3f1415 commit 55431f5

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

+stdlib/relative_to.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
other {mustBeTextScalar}
1717
end
1818

19-
if strempty(base) && strempty(other)
20-
rel = ".";
19+
if (strempty(base) && strempty(other)) || ...
20+
(stdlib.is_absolute(base) ~= stdlib.is_absolute(other))
21+
rel = "";
2122
return
2223
end
2324

@@ -43,18 +44,10 @@
4344
return
4445
end
4546

46-
bis = stdlib.is_absolute(base);
47-
ois = stdlib.is_absolute(other);
48-
49-
if bis ~= ois
50-
rel = "";
51-
return
52-
end
53-
5447
base = fullfile(base);
5548
other = fullfile(other);
5649

57-
if bis && ~(startsWith(base, other) || startsWith(other, base))
50+
if stdlib.is_absolute(base) && ~(startsWith(base, other) || startsWith(other, base))
5851
rel = "";
5952
else
6053
% https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getrelativepath

test/TestRelative.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function test_proximate_to(tc, pp)
2727

2828
function p = init_rel()
2929

30-
p = {{"", "", "."}, ...
30+
p = {{"", "", ""}, ...
3131
{"Hello", "Hello", "."}, ...
3232
{"Hello", "Hello/", "."}, ...
3333
{"a/./b", "a/b", "."}, ...

0 commit comments

Comments
 (0)