Skip to content

Commit 34d1257

Browse files
committed
relative_to, proximate_to: empty for URL
1 parent 749ea7b commit 34d1257

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

+stdlib/proximate_to.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
r = stdlib.relative_to(base, other);
1010

11-
if ~stdlib.len(r)
11+
if ~stdlib.len(r) && ~stdlib.is_url(other)
1212
r = other;
1313
end
1414

+stdlib/relative_to.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
other (1,1) string
77
end
88

9+
r = "";
10+
11+
if stdlib.is_url(base) || stdlib.is_url(other), return, end
12+
913
% must remove trailing slashes
1014
b1 = stdlib.drop_slash(base);
1115
o1 = stdlib.drop_slash(other);

test/TestRelative.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ function java_required(tc)
1515
methods (Test)
1616

1717
function test_relative_to(tc, pr)
18-
tc.verifyEqual(stdlib.relative_to(pr{1}, pr{2}), pr{3}, "relative_to(" + pr{1} + "," + pr{2}+")")
18+
tc.verifyEqual(stdlib.relative_to(pr{1}, pr{2}), pr{3}, ...
19+
"relative_to(" + pr{1} + "," + pr{2}+")")
1920
end
2021

2122
function test_proximate_to(tc, pp)
22-
tc.verifyEqual(stdlib.proximate_to(pp{1}, pp{2}), pp{3}, "proximate_to(" + pp{1} + "," + pp{2}+")")
23+
tc.verifyEqual(stdlib.proximate_to(pp{1}, pp{2}), pp{3}, ...
24+
"proximate_to(" + pp{1} + "," + pp{2}+")")
2325
end
2426

2527
end
@@ -75,4 +77,7 @@ function test_proximate_to(tc, pp)
7577

7678
p{end}{3} = "d:/path";
7779
end
80+
81+
p{end+1} = {"file:///", "file:///", ""};
82+
7883
end

0 commit comments

Comments
 (0)