fix: join ntfy topic prefix with hyphen
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user