From 22bebfc46ef5f4b5eaac8cbe7343dacdc42a1977 Mon Sep 17 00:00:00 2001 From: Mie Date: Fri, 7 Jun 2024 19:04:20 +0900 Subject: [PATCH 1/3] fix: response type for naifu --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 57f0489..3e2fdad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -413,7 +413,7 @@ export function apply(ctx: Context, config: Config) { method: 'POST', timeout: config.requestTimeout, // Since novelai's latest interface returns an application/x-zip-compressed, a responseType must be passed in - responseType: ['login', 'token'].includes(config.type) ? 'arraybuffer' : 'json', + responseType: config.type === 'naifu' ? 'text' : ['login', 'token'].includes(config.type) ? 'arraybuffer' : 'json', headers: { ...config.headers, ...getHeaders(), From 53bc5a5842a101a474f244f2a1964443f2c73d4e Mon Sep 17 00:00:00 2001 From: Mie Date: Sat, 8 Jun 2024 01:42:14 +0900 Subject: [PATCH 2/3] fix: remove trailing newlines from naifu --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 3e2fdad..c105c06 100644 --- a/src/index.ts +++ b/src/index.ts @@ -467,7 +467,9 @@ export function apply(ctx: Context, config: Config) { const b64 = Buffer.from(firstImageBuffer).toString('base64') return forceDataPrefix(b64, 'image/png') } - + if (config.type === 'naifu') { + return forceDataPrefix(res.data?.trimEnd().slice(27)) + } return forceDataPrefix(res.data?.slice(27)) } From 9ec66aea2de0ab0f94aff1703980b5f420c4540c Mon Sep 17 00:00:00 2001 From: Mie Date: Sun, 9 Jun 2024 01:58:17 +0900 Subject: [PATCH 3/3] fix: remove trailing newlines --- src/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index c105c06..c3aebba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -467,10 +467,7 @@ export function apply(ctx: Context, config: Config) { const b64 = Buffer.from(firstImageBuffer).toString('base64') return forceDataPrefix(b64, 'image/png') } - if (config.type === 'naifu') { - return forceDataPrefix(res.data?.trimEnd().slice(27)) - } - return forceDataPrefix(res.data?.slice(27)) + return forceDataPrefix(res.data?.trimEnd().slice(27)) } let dataUrl: string, count = 0