Comparing version 2.7.0 to 2.8.0
# WebDAV-Client changelog | ||
## v2.8.0 | ||
_2018-05-26_ | ||
* Remove `path` dependency | ||
## v2.7.0 | ||
@@ -4,0 +9,0 @@ _2019-05-23_ |
@@ -86,3 +86,3 @@ "use strict"; | ||
* @param {String} remoteURL The remote address of the webdav server | ||
* @param {CreateClientOptions=} options Client options | ||
* @param {CreateClientOptions=} opts Client options | ||
* @returns {ClientInterface} A new client interface instance | ||
@@ -109,4 +109,14 @@ * @memberof module:WebDAV | ||
*/ | ||
function createClient(remoteURL, { username, password, httpAgent, httpsAgent, token = null } = {}) { | ||
const baseOptions = { | ||
function createClient(remoteURL, opts = {}) { | ||
if (!opts || typeof opts !== "object") { | ||
throw new Error("Options must be an object, if specified"); | ||
} | ||
const username = opts.username, | ||
password = opts.password, | ||
httpAgent = opts.httpAgent, | ||
httpsAgent = opts.httpsAgent; | ||
var _opts$token = opts.token; | ||
const token = _opts$token === undefined ? null : _opts$token; | ||
const runtimeOptions = { | ||
headers: {}, | ||
@@ -120,5 +130,5 @@ remotePath: urlTools.extractURLPath(remoteURL), | ||
if (username) { | ||
baseOptions.headers.Authorization = authTools.generateBasicAuthHeader(username, password); | ||
runtimeOptions.headers.Authorization = authTools.generateBasicAuthHeader(username, password); | ||
} else if (token && typeof token === "object") { | ||
baseOptions.headers.Authorization = authTools.generateTokenAuthHeader(token); | ||
runtimeOptions.headers.Authorization = authTools.generateTokenAuthHeader(token); | ||
} | ||
@@ -137,3 +147,3 @@ return { | ||
copyFile: function copyFile(remotePath, targetRemotePath, options) { | ||
const copyOptions = merge(baseOptions, options || {}); | ||
const copyOptions = merge(runtimeOptions, options || {}); | ||
return copy.copyFile(remotePath, targetRemotePath, copyOptions); | ||
@@ -152,3 +162,3 @@ }, | ||
createDirectory: function createDirectory(dirPath, options) { | ||
const createOptions = merge(baseOptions, options || {}); | ||
const createOptions = merge(runtimeOptions, options || {}); | ||
return createDir.createDirectory(dirPath, createOptions); | ||
@@ -168,3 +178,3 @@ }, | ||
createReadStream: function createReadStream(remoteFilename, options) { | ||
const createOptions = merge(baseOptions, options || {}); | ||
const createOptions = merge(runtimeOptions, options || {}); | ||
return createStream.createReadStream(remoteFilename, createOptions); | ||
@@ -184,3 +194,3 @@ }, | ||
createWriteStream: function createWriteStream(remoteFilename, options) { | ||
const createOptions = merge(baseOptions, options || {}); | ||
const createOptions = merge(runtimeOptions, options || {}); | ||
return createStream.createWriteStream(remoteFilename, createOptions); | ||
@@ -199,3 +209,3 @@ }, | ||
deleteFile: function deleteFile(remotePath, options) { | ||
const deleteOptions = merge(baseOptions, options || {}); | ||
const deleteOptions = merge(runtimeOptions, options || {}); | ||
return deletion.deleteFile(remotePath, deleteOptions); | ||
@@ -214,3 +224,3 @@ }, | ||
getDirectoryContents: function getDirectoryContents(remotePath, options) { | ||
const getOptions = merge(baseOptions, options || {}); | ||
const getOptions = merge(runtimeOptions, options || {}); | ||
return directoryContents.getDirectoryContents(remotePath, getOptions); | ||
@@ -232,3 +242,3 @@ }, | ||
getFileContents: function getFileContents(remoteFilename, options) { | ||
const getOptions = merge(baseOptions, options || {}); | ||
const getOptions = merge(runtimeOptions, options || {}); | ||
getOptions.format = getOptions.format || "binary"; | ||
@@ -250,3 +260,3 @@ if (["binary", "text"].indexOf(getOptions.format) < 0) { | ||
getFileDownloadLink: function getFileDownloadLink(remoteFilename, options) { | ||
const getOptions = merge(baseOptions, options || {}); | ||
const getOptions = merge(runtimeOptions, options || {}); | ||
return getFile.getFileLink(remoteFilename, getOptions); | ||
@@ -264,3 +274,3 @@ }, | ||
getFileUploadLink: function getFileUploadLink(remoteFilename, options) { | ||
var putOptions = merge(baseOptions, options || {}); | ||
var putOptions = merge(runtimeOptions, options || {}); | ||
return putFile.getFileUploadLink(remoteFilename, putOptions); | ||
@@ -276,3 +286,3 @@ }, | ||
getQuota: function getQuota(options) { | ||
const getOptions = merge(baseOptions, options || {}); | ||
const getOptions = merge(runtimeOptions, options || {}); | ||
return quota.getQuota(getOptions); | ||
@@ -292,3 +302,3 @@ }, | ||
moveFile: function moveFile(remotePath, targetRemotePath, options) { | ||
const moveOptions = merge(baseOptions, options || {}); | ||
const moveOptions = merge(runtimeOptions, options || {}); | ||
return move.moveFile(remotePath, targetRemotePath, moveOptions); | ||
@@ -310,3 +320,3 @@ }, | ||
putFileContents: function putFileContents(remoteFilename, data, options) { | ||
const putOptions = merge(baseOptions, options || {}); | ||
const putOptions = merge(runtimeOptions, options || {}); | ||
return putFile.putFileContents(remoteFilename, data, putOptions); | ||
@@ -323,3 +333,3 @@ }, | ||
stat: function stat(remotePath, options) { | ||
const getOptions = merge(baseOptions, options || {}); | ||
const getOptions = merge(runtimeOptions, options || {}); | ||
return stats.getStat(remotePath, getOptions); | ||
@@ -326,0 +336,0 @@ } |
@@ -48,3 +48,3 @@ "use strict"; | ||
function propsToStat(props, filename, isDetailed = false) { | ||
const path = require("path"); | ||
const path = require("path-posix"); | ||
// Last modified time, raw size, item type and mime | ||
@@ -51,0 +51,0 @@ const lastMod = getSingleValue(getValueForKey("getlastmodified", props)); |
{ | ||
"name": "webdav", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "WebDAV client for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
665731
30
3903