Skip to content

Commit

Permalink
fix: '/' added to the end of the paths when an empty path is concaten…
Browse files Browse the repository at this point in the history
…ated

closes #47
  • Loading branch information
azubieta committed Mar 31, 2022
1 parent 571eca4 commit bf1bf54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ bool apprun_is_path_child_of(const char *path, const char *base) {

void apprun_concat_path(char *dest, const char *path) {
unsigned long path_len = strlen(path);
if (path_len == 0)
return;

unsigned long dest_len = strlen(dest);
unsigned long j = dest_len;

Expand Down
3 changes: 3 additions & 0 deletions test/common/path_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ void test_apprun_concat_path() {
apprun_concat_path(res, "/AppDir");
assert_str_eq(res, "/AppDir");

apprun_concat_path(res, "");
assert_str_eq(res, "/AppDir");

apprun_concat_path(res, "usr/");
assert_str_eq(res, "/AppDir/usr/");

Expand Down

0 comments on commit bf1bf54

Please sign in to comment.