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

Slash after one character directory is escaped #81

Closed
manabedaiki opened this issue Mar 12, 2018 · 2 comments
Closed

Slash after one character directory is escaped #81

manabedaiki opened this issue Mar 12, 2018 · 2 comments

Comments

@manabedaiki
Copy link

The slash after the single character directory is escaped.

const {encodePath} = require('webdav/dist/request')

// Expected: /AB/C/DE
// Actual  : /AB/C%2FDE
console.log(encodePath('/AB/C/DE'))

I think there is an error in the regular expression in encodePath function.

 function encodePath(path) {
     var replaced = path
+      .replace(/(^|[^\\])\\\\($|[^\\])/g, "$1" + SEP_PATH_WINDOWS + "$2")
+      .replace(/(^|[^\/])\/($|[^\/])/g, "$1" + SEP_PATH_POSIX + "$2");
     var formatted = encodeURIComponent(replaced);
     return formatted.split(SEP_PATH_WINDOWS).join("\\\\").split(SEP_PATH_POSIX).join("/");
 }
@perry-mitchell
Copy link
Owner

Thanks for reporting @manabedaiki! I'll look into this as soon as I can..

@perry-mitchell
Copy link
Owner

@manabedaiki this should be solved now: https://github.com/perry-mitchell/webdav-client/pull/87/files#diff-b3bdccd01810f825eb023abab8cc2b5eR20

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