Skip to content

Commit

Permalink
Merge pull request #325 from perry-mitchell/pull_324_test
Browse files Browse the repository at this point in the history
Pull 324 test
  • Loading branch information
perry-mitchell committed Nov 19, 2022
2 parents 6bcdbd2 + 935c966 commit 93d7781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/operations/directoryContents.ts
Expand Up @@ -33,7 +33,8 @@ export async function getDirectoryContents(
const response = await request(requestOptions);
handleResponseCode(context, response);
const davResp = await parseXML(response.data as string);
let files = getDirectoryFiles(davResp, context.remotePath, remotePath, options.details);
const _remotePath = remotePath.startsWith("/") ? remotePath : "/" + remotePath;
let files = getDirectoryFiles(davResp, context.remotePath, _remotePath, options.details);
if (options.glob) {
files = processGlobFilter(files, options.glob);
}
Expand Down
10 changes: 10 additions & 0 deletions test/node/operations/getDirectoryContents.spec.js
Expand Up @@ -85,6 +85,16 @@ describe("getDirectoryContents", function () {
});
});

it("returns correct results when calling without root slash", function () {
return this.client.getDirectoryContents("sub1").then(function (contents) {
expect(contents).to.have.lengthOf(2);
const sub1 = contents.find(item => item.basename === "irrelephant.jpg");
expect(sub1).to.be.ok;
const sub2 = contents.find(item => item.basename === "ยากจน #1.txt");
expect(sub2).to.be.ok;
});
});

it("returns correct file results for files with special characters", function () {
return this.client.getDirectoryContents("/sub1").then(function (contents) {
const sub1 = contents.find(function (item) {
Expand Down

0 comments on commit 93d7781

Please sign in to comment.