Skip to content

Commit 2c7c124

Browse files
committed
⬆️ improvement: correct encoder
1 parent 622e745 commit 2c7c124

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/api/services/ntfy.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { configPrivate } from '$config/private';
22
import { configPublic } from '$config/public';
33

4+
function encodeRFC2047B(str: string) {
5+
// Use Buffer in Node; fallback to btoa in browser-like envs
6+
const base64 = Buffer.from(str, 'utf8').toString('base64');
7+
return `=?UTF-8?B?${base64}?=`;
8+
}
9+
410
export async function sendToNtfyTopic({
511
body,
612
topic,
@@ -14,7 +20,7 @@ export async function sendToNtfyTopic({
1420
method: 'PUT',
1521
body: JSON.stringify({ message: body, topic }),
1622
headers: {
17-
Title: encodeURIComponent(title)
23+
Title: encodeRFC2047B(title)
1824
// Priority: 'urgent',
1925
// Tags: 'warning,skull'
2026
}

0 commit comments

Comments
 (0)