Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: perry-mitchell/webdav-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bd6c8e4ecc823abd0216338cf600ca195bfdd09e
Choose a base ref
...
head repository: perry-mitchell/webdav-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1692dcf77f1acd8e27622a8f63f2e6004b7c3f51
Choose a head ref

Commits on Oct 6, 2019

  1. Copy the full SHA
    d0ed91a View commit details

Commits on Jan 25, 2020

  1. Update dependencies

    perry-mitchell committed Jan 25, 2020
    Copy the full SHA
    9919271 View commit details
  2. Upgrade babel

    perry-mitchell committed Jan 25, 2020
    Copy the full SHA
    4b2e6a2 View commit details
  3. Upgrade webpack

    perry-mitchell committed Jan 25, 2020
    Copy the full SHA
    dee512e View commit details
  4. Copy the full SHA
    cb7ce24 View commit details
  5. Copy the full SHA
    3a64e70 View commit details
  6. Copy the full SHA
    acb85f2 View commit details
  7. Copy the full SHA
    e2bcff1 View commit details
  8. Fix web tests

    perry-mitchell committed Jan 25, 2020
    Copy the full SHA
    bcea138 View commit details

Commits on Jan 26, 2020

  1. Copy the full SHA
    cd5d32a View commit details
  2. Stub nodejs natives

    perry-mitchell committed Jan 26, 2020
    Copy the full SHA
    cdf414c View commit details
  3. Fix karma paths

    perry-mitchell committed Jan 26, 2020
    Copy the full SHA
    865ff6c View commit details
  4. Copy the full SHA
    1ab5eea View commit details
  5. Copy the full SHA
    588679b View commit details
  6. Setup web publish

    perry-mitchell committed Jan 26, 2020
    Copy the full SHA
    d6b9d36 View commit details
  7. Copy the full SHA
    bc51833 View commit details
  8. Update readme docs

    perry-mitchell committed Jan 26, 2020
    Copy the full SHA
    b2c1d24 View commit details
  9. Web support (#191)

    Web support
    perry-mitchell authored Jan 26, 2020
    Copy the full SHA
    4719cfd View commit details
  10. Copy the full SHA
    c42d4d5 View commit details
  11. Prepare v3.0.0

    perry-mitchell committed Jan 26, 2020
    Copy the full SHA
    b1971e7 View commit details
  12. 3.0.0

    perry-mitchell committed Jan 26, 2020
    Copy the full SHA
    41960f0 View commit details
  13. Copy the full SHA
    f99454a View commit details
  14. Copy the full SHA
    0c3f938 View commit details

Commits on Feb 4, 2020

  1. Merge pull request #176 from Glebka/master

    Discussed fix for #147
    perry-mitchell authored Feb 4, 2020
    Copy the full SHA
    a0e2273 View commit details
  2. Add nested-getter

    perry-mitchell committed Feb 4, 2020
    Copy the full SHA
    b9b7b5f View commit details
  3. Copy the full SHA
    a0f8ed4 View commit details
  4. Copy the full SHA
    70b71af View commit details

Commits on Feb 5, 2020

  1. Merge pull request #196 from perry-mitchell/bugfix/parsing-nextcloud

    Bugfix: Nextcloud / WebDAV result array parsing & normalisation
    perry-mitchell authored Feb 5, 2020
    Copy the full SHA
    5134ed5 View commit details
  2. Prepare 3.1.0

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    a3a013d View commit details
  3. 3.1.0

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    7502648 View commit details
  4. Add exists method

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    9662b1b View commit details
  5. Document exists

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    048ddaf View commit details
  6. Add tests for exists

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    8e48a6c View commit details
  7. Merge pull request #197 from perry-mitchell/exists

    Exists function
    perry-mitchell authored Feb 5, 2020
    Copy the full SHA
    892c448 View commit details
  8. Prepare 3.2.0

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    f06fa65 View commit details
  9. 3.2.0

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    c9f4b08 View commit details
  10. Audit packages

    perry-mitchell committed Feb 5, 2020
    Copy the full SHA
    b66d4bd View commit details

Commits on Mar 23, 2020

  1. Copy the full SHA
    c66cb40 View commit details

Commits on Mar 31, 2020

  1. Copy the full SHA
    0a302a6 View commit details
  2. Copy the full SHA
    636ef28 View commit details
  3. Copy the full SHA
    1b7878d View commit details
  4. Merge pull request #200 from h-bar/master

    provide callback for writeStream
    perry-mitchell authored Mar 31, 2020
    Copy the full SHA
    55eff8a View commit details

Commits on Apr 1, 2020

  1. Copy the full SHA
    99bfb95 View commit details

Commits on Apr 11, 2020

  1. Update dependencies

    perry-mitchell committed Apr 11, 2020
    Copy the full SHA
    2da89ad View commit details

Commits on Apr 19, 2020

  1. Tidy isPlainObject

    perry-mitchell authored Apr 19, 2020
    Copy the full SHA
    0c7acbc View commit details
  2. Copy the full SHA
    6608117 View commit details
  3. Merge pull request #201 from aleksandryackovlev/master

    Fix merging objects with prototypes
    perry-mitchell authored Apr 19, 2020
    Copy the full SHA
    4180ecb View commit details
  4. Use 'he'/browser-utils to handle html entities - fixes #198

    Some file URIs contain HTML entities when their remote filenames contain special characters, such as '&'. These are now decoded correctly.
    perry-mitchell committed Apr 19, 2020
    Copy the full SHA
    b693670 View commit details
  5. Copy the full SHA
    7fef287 View commit details
  6. Copy the full SHA
    2e6c3f8 View commit details
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"targets": {
"node": 6
"node": 10
},
"debug": true
}]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ test.js
node_modules
test/testContents
/dist
/web
15 changes: 5 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -7,21 +7,16 @@ matrix:
- NAME="Node stable"
- language: node_js
script: npm run test:node
node_js: "10"
node_js: "12"
env:
- NAME="Node 10"
- NAME="Node 12"
- language: node_js
script: npm run test:node
node_js: "8"
env:
- NAME="Node 8"
- language: node_js
script: npm run test:node
node_js: "6"
node_js: "10"
env:
- NAME="Node 6"
- NAME="Node 10"
- language: node_js
node_js: "8"
node_js: "12"
sudo: required
env:
- NAME="Web"
45 changes: 42 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,9 @@
<dt><a href="#encodePath">encodePath(path)</a> ⇒ <code>String</code></dt>
<dd><p>Encode a path for use with WebDAV servers</p>
</dd>
<dt><a href="#joinURL">joinURL(...parts)</a> ⇒ <code>String</code></dt>
<dd><p>Join URL segments</p>
</dd>
<dt><a href="#prepareRequestOptions">prepareRequestOptions(requestOptions, methodOptions)</a></dt>
<dd><p>Process request options before being passed to Axios</p>
</dd>
@@ -123,6 +126,18 @@ Encode a path for use with WebDAV servers
| --- | --- | --- |
| path | <code>String</code> | The path to encode |

<a name="joinURL"></a>

## joinURL(...parts) ⇒ <code>String</code>
Join URL segments

**Kind**: global function
**Returns**: <code>String</code> - A joined URL string

| Param | Type | Description |
| --- | --- | --- |
| ...parts | <code>String</code> | URL segments to join |

<a name="prepareRequestOptions"></a>

## prepareRequestOptions(requestOptions, methodOptions)
@@ -161,9 +176,10 @@ Client adapter
* [.copyFile(remotePath, targetRemotePath, [options])](#ClientInterface.copyFile) ⇒ <code>Promise</code>
* [.createDirectory(dirPath, [options])](#ClientInterface.createDirectory) ⇒ <code>Promise</code>
* [.createReadStream(remoteFilename, [options])](#ClientInterface.createReadStream) ⇒ <code>Readable</code>
* [.createWriteStream(remoteFilename, [options])](#ClientInterface.createWriteStream) ⇒ <code>Writeable</code>
* [.createWriteStream(remoteFilename, [options], [callback])](#ClientInterface.createWriteStream) ⇒ <code>Writeable</code>
* [.customRequest(remotePath, [requestOptions], [options])](#ClientInterface.customRequest) ⇒ <code>Promise.&lt;Any&gt;</code>
* [.deleteFile(remotePath, [options])](#ClientInterface.deleteFile) ⇒ <code>Promise</code>
* [.exists(remotePath, [options])](#ClientInterface.exists) ⇒ <code>Promise.&lt;Boolean&gt;</code>
* [.getDirectoryContents(remotePath, [options])](#ClientInterface.getDirectoryContents) ⇒ <code>Promise.&lt;Array.&lt;Stat&gt;&gt;</code>
* [.getFileContents(remoteFilename, [options])](#ClientInterface.getFileContents) ⇒ <code>Promise.&lt;(Buffer\|String)&gt;</code>
* [.getFileDownloadLink(remoteFilename, [options])](#ClientInterface.getFileDownloadLink) ⇒ <code>String</code>
@@ -228,7 +244,7 @@ const remote = client.createReadStream("/data.zip");
```
<a name="ClientInterface.createWriteStream"></a>

### ClientInterface.createWriteStream(remoteFilename, [options]) ⇒ <code>Writeable</code>
### ClientInterface.createWriteStream(remoteFilename, [options], [callback]) ⇒ <code>Writeable</code>
Create a writeable stream to a remote file

**Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
@@ -238,6 +254,7 @@ Create a writeable stream to a remote file
| --- | --- | --- |
| remoteFilename | <code>String</code> | The file to write to |
| [options] | [<code>PutOptions</code>](#PutOptions) | Options for the request |
| [callback] | <code>function</code> | Optional callback to fire once the request has finished |

**Example**
```js
@@ -286,6 +303,26 @@ Delete a remote file
```js
await client.deleteFile("/some/file.txt");
```
<a name="ClientInterface.exists"></a>

### ClientInterface.exists(remotePath, [options]) ⇒ <code>Promise.&lt;Boolean&gt;</code>
Check if a remote file or directory exists

**Kind**: static method of [<code>ClientInterface</code>](#ClientInterface)
**Returns**: <code>Promise.&lt;Boolean&gt;</code> - A promise that resolves with true if the path exists
or false if it does not

| Param | Type | Description |
| --- | --- | --- |
| remotePath | <code>String</code> | The remote path to check |
| [options] | [<code>UserOptions</code>](#UserOptions) | The options for the request |

**Example**
```js
if (await client.exists("/some-path/file.txt")) {
// Do something
}
```
<a name="ClientInterface.getDirectoryContents"></a>

### ClientInterface.getDirectoryContents(remotePath, [options]) ⇒ <code>Promise.&lt;Array.&lt;Stat&gt;&gt;</code>
@@ -425,6 +462,7 @@ Options for creating a resource
| Name | Type | Description |
| --- | --- | --- |
| [overwrite] | <code>Boolean</code> | Whether or not to overwrite existing files (default: true) |
| [maxBodyLength] | <code>Number</code> | The maximum amount of bytes to upload (default: 10 MiB) (only in nodejs-environments) |

<a name="OptionsWithFormat"></a>

@@ -438,6 +476,7 @@ Options with headers and format
| --- | --- | --- |
| format | <code>String</code> | The format to use (text/binary) |
| [details] | <code>Boolean</code> | Provided detailed response information, such as response headers (defaults to false). Only available on requests that return result data. |
| [maxContentLength] | <code>Number</code> | The maximum amount of bytes to download (default: 10 MiB) |

<a name="OptionsForAdvancedResponses"></a>

@@ -499,7 +538,7 @@ A stat result
| --- | --- | --- |
| filename | <code>String</code> | The full path and filename of the remote item |
| basename | <code>String</code> | The base filename of the remote item, without the path |
| lastmod | <code>String</code> | The last modification date (eg. "Sun, 13 Mar 2016 04:23:32 GMT") |
| lastmod | <code>String</code> \| <code>null</code> | The last modification date (eg. "Sun, 13 Mar 2016 04:23:32 GMT") |
| size | <code>Number</code> | The size of the remote item |
| type | <code>String</code> | The type of the item (file/directory) |
| [mime] | <code>String</code> | The file mimetype (not present on directories) |
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
# WebDAV-Client changelog

## v3.6.2
_2021-01-06_

* **Security Patches**:
* [#232](https://github.com/perry-mitchell/webdav-client/issues/232) Axios server-side request forgery vulerability ([CVE-2020-28168](https://github.com/advisories/GHSA-4w2v-q235-vp99))

## v3.6.1
_2020-10-15_

* **Bugfixes**:
* [#221](https://github.com/perry-mitchell/webdav-client/issues/221) Stat function erroneously decodes paths with `%` in them

## v3.6.0
_2020-10-12_

* [#220](https://github.com/perry-mitchell/webdav-client/pull/220) `maxBodyLength` option for changing written files max size
* **Bugfixes**:
* [#218](https://github.com/perry-mitchell/webdav-client/issues/218) Invalid response error - No root multistatus

## v3.5.0
_2020-10-08_

* Upgrade dependencies (major versions)
* [axios upgrade -> 0.20](https://github.com/axios/axios/blob/master/CHANGELOG.md#0200-august-20-2020)

## v3.4.0
_2020-10-08_

* **Bugfixes**:
* [#215](https://github.com/perry-mitchell/webdav-client/pull/215) Excessive memory usage when uploading big files (axios max-redirects)
* [#213](https://github.com/perry-mitchell/webdav-client/pull/213) `getDirectoryContents` fails for directories with `&` in the name

## v3.3.0
_2020-04-19_

* Node 10 build configuration
* [#201](https://github.com/perry-mitchell/webdav-client/pull/201) Improved object merging for configurations (no merging instances)
* [#200](https://github.com/perry-mitchell/webdav-client/pull/200) `createWriteStream` callback support (when request finishes finishes)
* Improved filename decoding
* **Bugfix**:
* [#198](https://github.com/perry-mitchell/webdav-client/issues/198) Encoded characters in directory contents (HTML entities)

## v3.2.0
_2020-02-05_

* `exists` method

## v3.1.0
_2020-02-05_

* Improved parsing logic for more robust handling of various PROPFIND requests
* **Bugfix**:
* [#194](https://github.com/perry-mitchell/webdav-client/issues/194) Several properties not defined in directory-contents / stats payloads
* [#147](https://github.com/perry-mitchell/webdav-client/issues/147) `Content-length` header being attached to stream requests erroneously

## v3.0.0
_2020-01-26_

* Removed support for NodeJS < 10
* Web support
* Replaced XML parsing library (no dependencies, no streaming - better web support)
* `createReadStream` and `createWriteStream` stubbed but disabled in web version

## v2.10.2
_2020-01-25_

50 changes: 46 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,13 +10,31 @@ WebDAV is a well-known, stable and highly flexible protocol for interacting with

This library provides a **WebDAV client** interface that makes interacting with WebDAV enabled services easy. The API returns promises and resolve with the results. It parses and prepares directory-contents requests for easy consumption, as well as providing methods for fetching things like file stats and quotas.

This library is compatibale with NodeJS version 6 and above (for version 4 support, use versions in the range of `1.*`). Version 1.x is now in maintenance mode and will receive no further feature additions. It will receive the odd bug fix when necessary.

Please read the [contribution guide](CONTRIBUTING.md) if you plan on making an issue or PR.

### Node support

This library is compatibale with **NodeJS version 10** and above (For version 6/8 support, use versions in the range of `2.*`. For version 4 support, use versions in the range of `1.*`). Version 2.x is now in maintenance mode and will receive no further feature additions. It will receive the odd bug fix when necessary. Version 1.x is no longer supported.

### Usage in the Browser

No transpiled package is provided, however it should be fine to transpile it with Webpack and Rollup (tested with Webpack in [external projects](https://github.com/buttercup/buttercup-browser-extension/blob/f980416d8c97e627ff9d8f3e1f48d09fcdfd53df/source/setup/library/remote.js#L1)). You must make sure to transpile/bundle all necessary WebDAV client dependencies, **including** NodeJS built-ins like `path`.
As of version 3, WebDAV client is now supported in the browser. The compilation settings specify a minimum supported browser version of Internet Explorer 11, however testing in this browser is not performed regularly.

_Although you may choose to transpile this library's default entry point (NodeJS) yourself, it is not advised - use the dedicated web version instead._

You can use the web version via a different entry point:

```javascript
import { createClient } from "webdav/web";
```

The browser version uses a UMD-style module definition, meaning you can simply load the library within your browser using a `<script>` tag. When using this method the library is made available on the window object as such: `window.WebDAV`. For example:

```javascript
const client = window.WebDAV.createClient(/* ... */);
```

**NB:** Streams are not available within the browser, so `createReadStream` and `createWriteStream` are just stubbed. Calling them will throw an exception.

## Installation

@@ -126,7 +144,17 @@ Create a read stream targeted at a remote file:
```javascript
client
.createReadStream("/video.mp4")
.pipe(fs.createWriteStream("~/video.np4"));
.pipe(fs.createWriteStream("~/video.mp4"));
```

If you want to stream only part of the file, you can specify the `range` in the options argument:

```javascript
client
.createReadStream(
"/video.mp4",
{ range: { start: start, end: end } }
).pipe(fs.createWriteStream("~/video.mp4"));
```

#### createWriteStream
@@ -146,6 +174,16 @@ Delete a remote file:
await client.deleteFile("/tmp.dat");
```

### exists

Check if a file or directory exists:

```javascript
if (await client.exists("/some/path") === false) {
await client.createDirectory("/some/path");
}
```

#### getDirectoryContents

Get the contents of a remote directory. Returns an array of [item stats](#item-stat).
@@ -179,6 +217,8 @@ Text files can also be fetched:
const str = await client.getFileContents("/config.json", { format: "text" });
```

Specify the `maxContentLength` option to alter the maximum number of bytes the client can receive in the request. **NodeJS only**.

#### getFileDownloadLink

Return a public link where a file can be downloaded. **This exposes authentication details in the URL**.
@@ -230,6 +270,8 @@ await client.putFileContents("/my/file.jpg", imageBuffer, { overwrite: false });
await client.putFileContents("/my/file.txt", str);
```

Specify the `maxBodyLength` option to alter the maximum number of bytes the client can send in the request. **NodeJS only**.

Handling Upload Progress (browsers only):
*This uses the axios onUploadProgress callback which uses the native XMLHttpRequest [progress event](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestEventTarget/onprogress).*

Loading