-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Added a new function and change some es6 features to es5 #86
Conversation
- getFileUploadLink function - changed es6 syntax to es5 for electron-builder support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addition looks good, but could you please revert the ES5 changes? They're not required.
source/auth.js
Outdated
@@ -4,10 +4,10 @@ function generateBasicAuthHeader(username, password) { | |||
return "Basic " + Buffer.from(username + ":" + password).toString("base64"); | |||
} | |||
function generateTokenAuthHeader(tokenInfo) { | |||
return `${tokenInfo.token_type} ${tokenInfo.access_token}`; | |||
return tokenInfo.token_type + " " + tokenInfo.access_token; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source/auth.js
Outdated
generateBasicAuthHeader, | ||
generateTokenAuthHeader | ||
generateBasicAuthHeader: generateBasicAuthHeader, | ||
generateTokenAuthHeader: generateTokenAuthHeader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be reverted due to it not being required.
source/factory.js
Outdated
@@ -226,5 +239,5 @@ function createClient(remoteURL, username, password) { | |||
} | |||
|
|||
module.exports = { | |||
createClient | |||
createClient: createClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here..
source/interface/createStream.js
Outdated
createReadStream, | ||
createWriteStream | ||
createReadStream: createReadStream, | ||
createWriteStream: createWriteStream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here..
@@ -70,5 +70,5 @@ function getDirectoryFiles(result, serverBasePath, requestPath) { | |||
} | |||
|
|||
module.exports = { | |||
getDirectoryContents | |||
getDirectoryContents: getDirectoryContents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here..
source/interface/getFile.js
Outdated
@@ -36,7 +36,7 @@ function getFileLink(filePath, options) { | |||
} | |||
const authPart = options.headers.Authorization.replace(/^Basic /i, "").trim(); | |||
const authContents = Buffer.from(authPart, "base64").toString("utf8"); | |||
fetchURL = fetchURL.replace(/^https?:\/\//, `${protocol}://${authContents}@`); | |||
fetchURL = fetchURL.replace(/^https?:\/\//, protocol + "://" + authContents + "@"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here 😊
source/interface/putFile.js
Outdated
throw new Error("Failed retrieving download link: Invalid authorisation method"); | ||
} | ||
var authPart = options.headers.Authorization.replace(/^Basic /i, "").trim(); | ||
var authContents = Buffer.from(authPart, "base64").toString("utf8"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use const/let (stylistic choice, to match rest of repo).
source/interface/putFile.js
Outdated
module.exports = { | ||
putFileContents: putFileContents | ||
putFileContents: putFileContents, | ||
getFileUploadLink: getFileUploadLink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yoeven These can still be changed..
source/merge.js
Outdated
@@ -5,5 +5,5 @@ function merge(...args) { | |||
} | |||
|
|||
module.exports = { | |||
merge | |||
merge: merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here..
Hi, @perry-mitchell I've reverted the es5 changes as stated. I seem to get a minifying file error from building a react project if I use the es6 features for this module. Based on few threads that I read online, it seems like es6 is an issue even though the oldest nodejs supports it (thread links here & here). |
source/interface/putFile.js
Outdated
module.exports = { | ||
putFileContents: putFileContents | ||
putFileContents: putFileContents, | ||
getFileUploadLink: getFileUploadLink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yoeven These can still be changed..
That sounds strange @yoeven - What version of node are you running? You can see here that webdav uses the built version of this library when required by other libraries. The code that is seen externally should be Node v4 compatible, so it shouldn't cause any issues. At this stage I would suggest that it's a configuration issue in your react app and not something to do with this library. If you disagree or find an issue, definitely feel free to open a separate issue so we can debug it. |
I'm using version 9.8.0 and Yeah, it could possibly be something with the configuration, I'll do a bit more research and if anything I'll post an issue. For now, we can stick with just the new function for this PR. Thanks @perry-mitchell |
Thanks! And thanks for the submission. I’ll merge soon.
|
Just to remind: I'll merge after the latest changes are made. Thanks! |
1. I've added
getFileUploadLink
which works likegetFileDownloadLink
. Similarly, it also allows users to use the request module to process the upload from their end.A simple example:
var link = client.getFileUploadLink(RemoteDirToUploadTo + "/" + filename);
A simple example with the request and process-request modules:
2. I've changed few es6 features to es5 features as react building process takes any node modules with es6 syntax as an error and breaks the build.