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

getDirectoryContents filename parse bug #54

Closed
zh99998 opened this issue Jul 28, 2017 · 3 comments
Closed

getDirectoryContents filename parse bug #54

zh99998 opened this issue Jul 28, 2017 · 3 comments

Comments

@zh99998
Copy link
Contributor

zh99998 commented Jul 28, 2017

when directory name is included in base url, getDirectoryContents will return wrong result.

for example I have requested base url http://.../storage/test1 and request to list /te directory
in my server it is an empty directory, so empty array is expected, but got ['/test1/te']

in parse.js processDirectoryResultFilename

var pos = resultFilename.indexOf(dirPath);

I think bug is here.
'/storage/test1/te'.indexOf('/te') will got 8, which expected 14.

maybe we should save base url when creating client, or... does lastIndexOf() works?

@zh99998
Copy link
Contributor Author

zh99998 commented Jul 28, 2017

well lastIndexOf not works.

seems we have to store base url from create client
if I request directory /, base url is /storage/test1, and there is one test2 directory inner test1
server will response 2 item /storage/test1/, /storage/test1/test2/
simple string analysis could never tell apart which is base href and which is directory.

@perry-mitchell
Copy link
Owner

Ah good catch @zh99998 that's definitely a bad issue..

seems we have to store base url from create client

Yeah it looks like we need a bit of an overhaul there..

@perry-mitchell
Copy link
Owner

perry-mitchell commented Jul 30, 2017

After looking at the code, this looks like a deeper architectural issue.. I haven't considered webdav servers and subdirectory hosting. If the server is hosted on a sub directory then these pathing issues can be found easily. Need to consider what the best way forward is..

EDIT: Looks like I'll undertake a more major refactoring. There's just too much wrong and unclear with the current codebase. I've already got a new getDirectoryContents method rewritten from scratch. After I've got the API fully re-implemented with new unit tests, I'll consider submitting a new RC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants