Browse Source

Fix MOVE operations on non-Apache hosts. Fixes #89.

dom111 2 years ago
parent
commit
41ea62f188
4 changed files with 8 additions and 4 deletions
  1. 1 1
      package.json
  2. 7 2
      src/lib/DAV.ts
  3. 0 0
      src/webdav-min.js
  4. 0 1
      tests/functional/List.test.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "webdav-js",
   "name": "webdav-js",
-  "version": "2.1.0",
+  "version": "2.1.1",
   "description": "WebDAV functionality intended for use as a bookmarklet or to make a simple Apache webserver an interactive WebDAV environment.",
   "description": "WebDAV functionality intended for use as a bookmarklet or to make a simple Apache webserver an interactive WebDAV environment.",
   "repository": {
   "repository": {
     "type": "git",
     "type": "git",

+ 7 - 2
src/lib/DAV.ts

@@ -3,6 +3,7 @@ import HTTP from './HTTP';
 import Response from './DAV/Response';
 import Response from './DAV/Response';
 import joinPath from './joinPath';
 import joinPath from './joinPath';
 import trailingSlash from './trailingSlash';
 import trailingSlash from './trailingSlash';
+import Entry from './DAV/Entry';
 
 
 type ConstructorOptions = {
 type ConstructorOptions = {
   bypassCheck?: boolean;
   bypassCheck?: boolean;
@@ -150,12 +151,16 @@ export default class DAV extends EventObject {
     );
     );
   }
   }
 
 
-  async move(from, to, entry = null) {
+  async move(from: string, to: string, entry: Entry) {
+    const destination = this.#validDestination(to);
+
     return this.#dispatchWithEvents(
     return this.#dispatchWithEvents(
       () =>
       () =>
         this.#http.MOVE(from, {
         this.#http.MOVE(from, {
           headers: {
           headers: {
-            Destination: this.#validDestination(to),
+            Destination: entry.directory
+              ? trailingSlash(destination)
+              : destination,
           },
           },
         }),
         }),
       'move',
       'move',

File diff suppressed because it is too large
+ 0 - 0
src/webdav-min.js


+ 0 - 1
tests/functional/List.test.ts

@@ -93,7 +93,6 @@ describe('WebDAV.js', () => {
 
 
       await page.click('[data-full-path="/new-directory/"]');
       await page.click('[data-full-path="/new-directory/"]');
 
 
-
       await page.waitForTimeout(200);
       await page.waitForTimeout(200);
 
 
       await expect(await page.$$('main ul li')).toHaveLength(1);
       await expect(await page.$$('main ul li')).toHaveLength(1);

Some files were not shown because too many files changed in this diff