chore: remove trailing slash when submitting
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
Header,
|
||||
Message,
|
||||
} from 'semantic-ui-react';
|
||||
import { API, showError, showSuccess } from '../helpers';
|
||||
import { API, removeTrailingSlash, showError, showSuccess } from '../helpers';
|
||||
|
||||
const PushSetting = () => {
|
||||
let [inputs, setInputs] = useState({
|
||||
@@ -102,7 +102,7 @@ const PushSetting = () => {
|
||||
data.ding_webhook_secret = inputs.ding_webhook_secret;
|
||||
break;
|
||||
case 'bark':
|
||||
data.bark_server = inputs.bark_server;
|
||||
data.bark_server = removeTrailingSlash(inputs.bark_server);
|
||||
data.bark_secret = inputs.bark_secret;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Divider, Form, Grid, Header, Message } from 'semantic-ui-react';
|
||||
import { API, showError } from '../helpers';
|
||||
import { API, removeTrailingSlash, showError } from '../helpers';
|
||||
|
||||
const SystemSetting = () => {
|
||||
let [inputs, setInputs] = useState({
|
||||
@@ -95,10 +95,7 @@ const SystemSetting = () => {
|
||||
};
|
||||
|
||||
const submitServerAddress = async () => {
|
||||
let ServerAddress = inputs.ServerAddress;
|
||||
if (ServerAddress.endsWith('/')) {
|
||||
ServerAddress = ServerAddress.slice(0, ServerAddress.length - 1);
|
||||
}
|
||||
let ServerAddress = removeTrailingSlash(inputs.ServerAddress);
|
||||
await updateOption('ServerAddress', ServerAddress);
|
||||
};
|
||||
|
||||
@@ -119,7 +116,10 @@ const SystemSetting = () => {
|
||||
|
||||
const submitWeChat = async () => {
|
||||
if (originInputs['WeChatServerAddress'] !== inputs.WeChatServerAddress) {
|
||||
await updateOption('WeChatServerAddress', inputs.WeChatServerAddress);
|
||||
await updateOption(
|
||||
'WeChatServerAddress',
|
||||
removeTrailingSlash(inputs.WeChatServerAddress)
|
||||
);
|
||||
}
|
||||
if (
|
||||
originInputs['WeChatAccountQRCodeImageURL'] !==
|
||||
@@ -170,7 +170,7 @@ const SystemSetting = () => {
|
||||
<Form.Group widths='equal'>
|
||||
<Form.Input
|
||||
label='服务器地址'
|
||||
placeholder='例如:https://yourdomain.com(注意没有最后的斜杠)'
|
||||
placeholder='例如:https://yourdomain.com'
|
||||
value={inputs.ServerAddress}
|
||||
name='ServerAddress'
|
||||
onChange={handleInputChange}
|
||||
@@ -316,7 +316,7 @@ const SystemSetting = () => {
|
||||
<Form.Input
|
||||
label='WeChat Server 服务器地址'
|
||||
name='WeChatServerAddress'
|
||||
placeholder='例如:https://yourdomain.com(注意没有最后的斜杠)'
|
||||
placeholder='例如:https://yourdomain.com'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='off'
|
||||
value={inputs.WeChatServerAddress}
|
||||
|
||||
@@ -89,3 +89,11 @@ export function showNotice(message) {
|
||||
export function openPage(url) {
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
export function removeTrailingSlash(url) {
|
||||
if (url.endsWith('/')) {
|
||||
return url.slice(0, -1);
|
||||
} else {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user