Skip to content

Commit 7bf7320

Browse files
committed
feat: 自动去除 api 参数末尾 /
1 parent 5d4c490 commit 7bf7320

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.15.63",
3+
"version": "2.15.64",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const processUrlApiConfig = async () => {
9494
.find(i => i[0] === 'magicpath');
9595
9696
if (hasApiParam) {
97-
const apiValue = decodeURIComponent(hasApiParam[1]);
97+
const apiValue = decodeURIComponent(hasApiParam[1]).replace(/\/$/, ''); // 去除末尾斜杠;
9898
urlApiValue.value = apiValue;
9999
urlApiError.value = '通过 URL 参数指定的 API 地址连接失败,请检查地址是否正确';
100100
hasUrlParams = true;

src/hooks/useHostAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const getHostAPIUrl = (): string => {
2525
apis.find(api => api.name === current)?.url ||
2626
import.meta.env.VITE_API_URL ||
2727
'https://sub.store'
28-
);
28+
).replace(/\/$/, ''); // 去除末尾斜杠;
2929
};
3030

3131
const setHostAPI = (hostAPI: HostAPIStorage) => {
@@ -167,7 +167,7 @@ export const useHostAPI = () => {
167167

168168
// 优先处理api参数
169169
if (apiUrl) {
170-
const url = decodeURIComponent(apiUrl[1]);
170+
const url = decodeURIComponent(apiUrl[1]).replace(/\/$/, ''); // 去除末尾斜杠;
171171
if (!url) return await errorCb?.();
172172

173173
// 检查是否已存在相同URL的API

0 commit comments

Comments
 (0)