Comparing version 5.0.0 to 5.1.0
# WebDAV-Client changelog | ||
## v5.1.0 | ||
_2023-05-29_ | ||
* [#342](https://github.com/perry-mitchell/webdav-client/issues/342) Support custom remote base directory (other than path specified in URL): `remoteBasePath` | ||
## v5.0.0 | ||
@@ -4,0 +9,0 @@ _2022-11-30_ |
@@ -19,3 +19,3 @@ import { extractURLPath } from "./tools/url.js"; | ||
export function createClient(remoteURL, options = {}) { | ||
const { authType: authTypeRaw = null, contactHref = DEFAULT_CONTACT_HREF, ha1, headers = {}, httpAgent, httpsAgent, password, token, username, withCredentials } = options; | ||
const { authType: authTypeRaw = null, remoteBasePath, contactHref = DEFAULT_CONTACT_HREF, ha1, headers = {}, httpAgent, httpsAgent, password, token, username, withCredentials } = options; | ||
let authType = authTypeRaw; | ||
@@ -27,2 +27,3 @@ if (!authType) { | ||
authType, | ||
remoteBasePath, | ||
contactHref, | ||
@@ -33,5 +34,5 @@ ha1, | ||
httpsAgent, | ||
password, | ||
remotePath: extractURLPath(remoteURL), | ||
remoteURL, | ||
password, | ||
token, | ||
@@ -38,0 +39,0 @@ username, |
import pathPosix from "path-posix"; | ||
import { joinURL, normaliseHREF } from "../tools/url.js"; | ||
import { encodePath, normalisePath } from "../tools/path.js"; | ||
import { encodePath, makePathAbsolute, normalisePath } from "../tools/path.js"; | ||
import { parseXML, prepareFileFromProps } from "../tools/dav.js"; | ||
@@ -23,4 +23,5 @@ import { request, prepareRequestOptions } from "../request.js"; | ||
const davResp = await parseXML(responseData); | ||
const _remotePath = remotePath.startsWith("/") ? remotePath : "/" + remotePath; | ||
let files = getDirectoryFiles(davResp, context.remotePath, _remotePath, options.details, options.includeSelf); | ||
const _remotePath = makePathAbsolute(remotePath); | ||
const remoteBasePath = makePathAbsolute(context.remoteBasePath || context.remotePath); | ||
let files = getDirectoryFiles(davResp, remoteBasePath, _remotePath, options.details, options.includeSelf); | ||
if (options.glob) { | ||
@@ -31,4 +32,4 @@ files = processGlobFilter(files, options.glob); | ||
} | ||
function getDirectoryFiles(result, serverBasePath, requestPath, isDetailed = false, includeSelf = false) { | ||
const serverBase = pathPosix.join(serverBasePath, "/"); | ||
function getDirectoryFiles(result, serverremoteBasePath, requestPath, isDetailed = false, includeSelf = false) { | ||
const serverBase = pathPosix.join(serverremoteBasePath, "/"); | ||
// Extract the response items (directory contents) | ||
@@ -35,0 +36,0 @@ const { multistatus: { response: responseItems } } = result; |
export declare function encodePath(filePath: string): string; | ||
export declare function getAllDirectories(directory: string): Array<string>; | ||
export declare function makePathAbsolute(pathStr: string): string; | ||
export declare function normalisePath(pathStr: string): string; |
@@ -26,2 +26,5 @@ import { Layerr } from "layerr"; | ||
} | ||
export function makePathAbsolute(pathStr) { | ||
return pathStr.startsWith("/") ? pathStr : "/" + pathStr; | ||
} | ||
export function normalisePath(pathStr) { | ||
@@ -28,0 +31,0 @@ let normalisedPath = pathStr; |
@@ -143,6 +143,6 @@ /// <reference types="node" /> | ||
onUploadProgress?: ProgressEventCallback; | ||
signal?: AbortSignal; | ||
transformResponse?: Array<(value: any) => any>; | ||
url?: string; | ||
withCredentials?: boolean; | ||
signal?: AbortSignal; | ||
} | ||
@@ -195,2 +195,3 @@ export interface RequestOptionsCustom extends RequestOptionsBase { | ||
authType: AuthType; | ||
remoteBasePath?: string; | ||
contactHref: string; | ||
@@ -215,2 +216,3 @@ digest?: DigestContext; | ||
authType?: AuthType; | ||
remoteBasePath?: string; | ||
contactHref?: string; | ||
@@ -217,0 +219,0 @@ ha1?: string; |
{ | ||
"name": "webdav", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "WebDAV client for NodeJS", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is too big to display
210144
1667