Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull 324 test #325

Merged
merged 2 commits into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/operations/directoryContents.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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