- FastAPI: preset assets 01–08, GET list/static, PUT /me/avatar/preset, safer uploaded-avatar path validation, preset_avatars + HTTP tests. - Expo: personal-info (library + presets), profile tab avatar, resolveApiMediaUrl, auth hooks cache sync, Web multipart helper, partial-save messaging + profile i18n. - Includes existing edits to conversation screen and voice use-player. Co-authored-by: Cursor <cursoragent@cursor.com>
15 lines
504 B
TypeScript
15 lines
504 B
TypeScript
import { config } from '@/core/config';
|
|
|
|
/** 将 API 返回的相对路径(如 `/api/auth/avatars/x.jpg`)转为可请求的绝对 URL。 */
|
|
export function resolveApiMediaUrl(
|
|
pathOrUrl: string | null | undefined,
|
|
): string | null {
|
|
if (pathOrUrl == null || pathOrUrl === '') return null;
|
|
if (/^https?:\/\//i.test(pathOrUrl)) return pathOrUrl;
|
|
if (pathOrUrl.startsWith('/')) {
|
|
const base = config.apiBaseUrl.replace(/\/$/, '');
|
|
return `${base}${pathOrUrl}`;
|
|
}
|
|
return pathOrUrl;
|
|
}
|