修改接口
This commit is contained in:
+10
-4
@@ -9,12 +9,18 @@ function toRelativeUrl(url) {
|
||||
if (url.startsWith(baseUrl)) {
|
||||
return url.replace(baseUrl, '');
|
||||
}
|
||||
// 移除其他可能的前缀
|
||||
// 从 BASE_URL 中提取主机名用于构建动态正则
|
||||
let hostname = ''
|
||||
try {
|
||||
hostname = new URL(baseUrl).hostname
|
||||
} catch (e) {
|
||||
hostname = ''
|
||||
}
|
||||
// 移除其他已知前缀
|
||||
const patterns = [
|
||||
/^https?:\/\/donghy\.top/,
|
||||
/^https?:\/\/110\.42\.255\.239(:\d+)?/,
|
||||
hostname ? new RegExp(`^https?://${hostname.replace(/\./g, '\\.')}(:\\d+)?`) : null,
|
||||
/^https?:\/\/localhost(:\d+)?/
|
||||
];
|
||||
].filter(Boolean)
|
||||
for (const pattern of patterns) {
|
||||
if (pattern.test(url)) {
|
||||
return url.replace(pattern, '');
|
||||
|
||||
Reference in New Issue
Block a user