Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions platforms/profile-editor/client/src/lib/utils/file-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ export function isHttpUrl(value?: string | null): boolean {
return !!value && /^(https?:)?\/\//i.test(value);
}

/**
* Anything the browser can render as-is: an http(s) or protocol-relative URL,
* an inline `data:` URI (avatars synced in from other platforms are often
* stored base64-inline) or a local `blob:` preview.
*/
export function isRenderableUrl(value?: string | null): boolean {
return isHttpUrl(value) || /^(data|blob):/i.test(value ?? '');
}

/**
* Resolve a stored profile asset (avatar/banner/cv/video) to a renderable URL.
* New uploads store a public eVault-blob URL and are used as-is. Legacy
* profiles stored a bare file-manager id — resolve it against the configured
* file-manager (defaulting to the public deployment) so the old asset renders.
* New uploads store a public eVault-blob URL and are used as-is, as are inline
* `data:` URIs. Legacy profiles stored a bare file-manager id — resolve it
* against the configured file-manager (defaulting to the public deployment) so
* the old asset renders.
*/
export function resolveAssetUrl(value?: string | null): string | null {
if (!value) return null;
if (isHttpUrl(value)) return value;
if (isRenderableUrl(value)) return value;
const base = (PUBLIC_FILE_MANAGER_BASE_URL || DEFAULT_FILE_MANAGER_BASE_URL).replace(
/\/$/,
''
Expand Down
Loading