refactor: code readability

This commit is contained in:
Nicolas Meienberger 2026-01-02 14:23:21 +01:00
parent a5242fa64a
commit d535f02536
2 changed files with 13 additions and 7 deletions

View file

@ -527,7 +527,9 @@ export const CreateNotificationForm = ({ onSubmit, mode = "create", initialValue
<FormControl>
<SecretInput {...field} placeholder="••••••••" />
</FormControl>
<FormDescription>Access token for server authentication, if required.</FormDescription>
<FormDescription>
Access token for server authentication. Will take precedence over username/password if set.
</FormDescription>
<FormMessage />
</FormItem>
)}

View file

@ -4,13 +4,17 @@ export function buildNtfyShoutrrrUrl(config: Extract<NotificationConfig, { type:
let shoutrrrUrl: string;
const params = new URLSearchParams();
const { username, password, accessToken } = config;
const auth =
config.accessToken
? `:${encodeURIComponent(config.accessToken)}@`
: config.username && config.password
? `${encodeURIComponent(config.username)}:${encodeURIComponent(config.password)}@`
: "";
let auth = "";
if (username && password) {
auth = `${encodeURIComponent(username)}:${encodeURIComponent(password)}@`;
}
if (accessToken) {
auth = `:${encodeURIComponent(accessToken)}@`;
}
if (config.serverUrl) {
const url = new URL(config.serverUrl);