From 443c359bf7baf33d8dfb6a5e1834215e36caccfa Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Sat, 14 Aug 2021 19:51:29 +0300 Subject: [PATCH] Use transformer for getFileContents as string fixes #267 --- source/operations/getFileContents.ts | 5 ++++- source/types.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/operations/getFileContents.ts b/source/operations/getFileContents.ts index 6abf4871..4373f784 100644 --- a/source/operations/getFileContents.ts +++ b/source/operations/getFileContents.ts @@ -13,6 +13,8 @@ import { WebDAVClientContext } from "../types"; +const TRANSFORM_RETAIN_FORMAT = (v: any) => v; + export async function getFileContents( context: WebDAVClientContext, filePath: string, @@ -62,7 +64,8 @@ async function getFileContentsString( { url: joinURL(context.remoteURL, encodePath(filePath)), method: "GET", - responseType: "text" + responseType: "text", + transformResponse: [TRANSFORM_RETAIN_FORMAT] }, context, options diff --git a/source/types.ts b/source/types.ts index 5404054d..2a834e38 100644 --- a/source/types.ts +++ b/source/types.ts @@ -146,6 +146,7 @@ interface RequestOptionsBase { method: string; onUploadProgress?: UploadProgressCallback; responseType?: string; + transformResponse?: Array<(value: any) => any>; url?: string; validateStatus?: (status: number) => boolean; withCredentials?: boolean;