fix: join ntfy topic prefix with hyphen

This commit is contained in:
2025-11-09 20:31:27 +01:00
parent 539759ed60
commit 36e6543abd
3 changed files with 39 additions and 14 deletions

View File

@@ -26,8 +26,10 @@ async function sendNtfyNotification(adminNtfy, userNtfy, payload) {
return;
}
const server = (userNtfy.serverUrl || adminNtfy.serverUrl || 'https://ntfy.sh').replace(/\/+$/, '');
const topicPrefix = adminNtfy.topicPrefix ? `${adminNtfy.topicPrefix.replace(/\/+$/, '')}/` : '';
const topic = `${topicPrefix}${userNtfy.topic.replace(/^\//, '')}`;
const sanitizedPrefix = (adminNtfy.topicPrefix || '').replace(/^-+|-+$/g, '');
const sanitizedTopic = (userNtfy.topic || '').replace(/^-+|-+$/g, '');
const separator = sanitizedPrefix && sanitizedTopic ? '-' : '';
const topic = `${sanitizedPrefix}${separator}${sanitizedTopic}` || sanitizedPrefix || sanitizedTopic;
const url = `${server}/${topic}`;
const headers = {
Title: payload.title,