Skip to content

Commit 072b7d6

Browse files
committed
join: don't coerce
1 parent b107d3e commit 072b7d6

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

+stdlib/join.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
%% JOIN join two paths with posix file separator
22

33
function p = join(base, other)
4-
arguments
5-
base (1,1) string
6-
other (1,1) string
7-
end
84

95
rno = stdlib.root_name(other);
106
rnb = stdlib.root_name(base);
@@ -18,9 +14,9 @@
1814

1915
if ~stdlib.strempty(rnb)
2016
if endsWith(rnb, ["/", filesep])
21-
p = rnb + other;
17+
p = append(rnb, other);
2218
else
23-
p = rnb + "/" + other;
19+
p = append(rnb, '/', other);
2420
end
2521
else
2622
p = other;
@@ -30,9 +26,9 @@
3026

3127
if ~stdlib.strempty(other)
3228
if endsWith(base, ["/", filesep])
33-
p = base + other;
29+
p = append(base, other);
3430
else
35-
p = base + "/" + other;
31+
p = append(base, '/', other);
3632
end
3733
else
3834
p = base;

test/TestJoin.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{"a/b/", "c", "a/b/c"}, ...
1010
{"/", "", "/"}, ...
1111
{"", "/", "/"}, ...
12-
{"a", "b", "a/b"}, ...
12+
{'a', 'b', 'a/b'}, ...
1313
{"a/b/../", "c/d/..", "a/b/../c/d/.."}, ...
1414
{"a/b", "..", "a/b/.."}, ...
1515
{"a/b", "c/d", "a/b/c/d"}, ...

0 commit comments

Comments
 (0)