sdfsdf
This commit is contained in:
@@ -276,6 +276,27 @@
|
||||
return formatDateByParts(value, true);
|
||||
}
|
||||
|
||||
function normalizeApiUrl(rawUrl) {
|
||||
const url = String(rawUrl || '');
|
||||
if (!url || !apiBase.includes('?path=')) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (!url.startsWith(apiBase)) {
|
||||
return url;
|
||||
}
|
||||
|
||||
const [baseRoot, basePath = ''] = apiBase.split('?path=');
|
||||
const suffix = url.slice(apiBase.length);
|
||||
const [routeSuffix, extraQuery = ''] = suffix.split('?');
|
||||
const normalizedPath = [basePath, routeSuffix]
|
||||
.map((part) => String(part || '').replace(/^\/+|\/+$/g, ''))
|
||||
.filter(Boolean)
|
||||
.join('/');
|
||||
|
||||
return `${baseRoot}?path=${encodeURIComponent(normalizedPath)}${extraQuery ? `&${extraQuery}` : ''}`;
|
||||
}
|
||||
|
||||
async function request(path, options) {
|
||||
const requestOptions = options && typeof options === 'object' ? { ...options } : {};
|
||||
const debugEnabled = !!debugBus.enabled;
|
||||
@@ -287,7 +308,7 @@
|
||||
const controller = new AbortController();
|
||||
const timeoutId = window.setTimeout(() => controller.abort(), timeoutMs);
|
||||
|
||||
const requestUrl = path;
|
||||
const requestUrl = normalizeApiUrl(path);
|
||||
const headers = { ...(requestOptions.headers || {}) };
|
||||
if (debugEnabled) {
|
||||
headers['X-Mining-Debug'] = '1';
|
||||
|
||||
Reference in New Issue
Block a user