mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 13:48:43 +00:00
* fix(premiere-uxp): scope sequence links by server endpoint and surface sync errors - Add optional endpoint property to LinkedSequenceAsset to record originating server - Implement normalizeEndpoint and isSameEndpoint helpers in utils/url - Skip polling foreign sequence links in autoSyncService when connected to a different server - Display informative Server: <host> badge and disable manual sync with tooltip for foreign links in SequencesView - Guard comment fallback in removeSequenceLink and link matching in FileListView by endpoint - Throw on non-200 responses in fetchAssetComments and display error toast on failed manual sync - Add comprehensive unit tests covering endpoint normalization, foreign link skipping, and error toast handling - Rebuild and package shumai-premiere.ccx * fix(premiere-uxp): filter out foreign endpoint sequence links from sequences tab - Filter all sequence links in SequencesView to only display links matching the current server endpoint - Filter existing sequence links in LinkSequenceDialog by endpoint so foreign sequences appear as ready to link on the current server - Ensure onLinkCountChange in FileListView and SequencesView only counts sequences linked to the active server - Add 'Browse Assets to Link' action button to the SequencesView unified empty state - Update SequencesView tests to verify foreign links are completely hidden and link counts are scoped - Rebuild and package shumai-premiere.ccx * fix(premiere-uxp): show file creation time on cards and remove sequence icon in link dialog * fix(premiere-uxp): remove browse button in sequences empty state
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/**
|
|
* Utility functions for URL manipulation and resolution in UXP plugins.
|
|
*/
|
|
|
|
/**
|
|
* Resolves an asset URL (such as a thumbnail or file download) against
|
|
* the user-configured Shumai endpoint.
|
|
*
|
|
* Handles:
|
|
* - Relative paths (/files/..., /api/...) by prepending the endpoint.
|
|
* - Absolute URLs (http://, https://) are preserved as-is.
|
|
*/
|
|
export function resolveAssetUrl(url?: string | null, endpoint?: string): string | undefined {
|
|
if (!url) return undefined
|
|
if (!endpoint) return url
|
|
|
|
const cleanEndpoint = endpoint.replace(/\/+$/, '')
|
|
|
|
// Handle relative URLs (e.g. /files/..., /api/...)
|
|
if (url.startsWith('/') && !url.startsWith('//')) {
|
|
return `${cleanEndpoint}${url}`
|
|
}
|
|
|
|
return url
|
|
}
|
|
|
|
/**
|
|
* Normalizes an endpoint URL by trimming whitespace, stripping trailing slashes,
|
|
* and converting to lower case for reliable comparison.
|
|
*/
|
|
export function normalizeEndpoint(endpoint?: string | null): string {
|
|
if (!endpoint) return ''
|
|
return endpoint.trim().replace(/\/+$/, '').toLowerCase()
|
|
}
|
|
|
|
/**
|
|
* Checks if two endpoints refer to the same server URL.
|
|
*/
|
|
export function isSameEndpoint(ep1?: string | null, ep2?: string | null): boolean {
|
|
const n1 = normalizeEndpoint(ep1)
|
|
const n2 = normalizeEndpoint(ep2)
|
|
return Boolean(n1 && n2 && n1 === n2)
|
|
}
|