refactor: code readability
This commit is contained in:
parent
a5242fa64a
commit
d535f02536
2 changed files with 13 additions and 7 deletions
|
|
@ -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>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue