Fix 0.20.x image preview URLs by prioritizing uid check

Reorder fallback checks in buildV1ResourceStreamUrl to prioritize uid-like identifiers before numeric IDs. This fixes image preview URLs in Memos 0.20.x that incorrectly used numeric IDs instead of proper UIDs. Applied to Chrome, Edge, and Firefox extensions. Updated changelog accordingly.
This commit is contained in:
jonny
2026-08-05 12:19:16 +08:00
parent e01ea6b0df
commit afbb7ac5cc
4 changed files with 16 additions and 16 deletions
+5 -5
View File
@@ -541,6 +541,11 @@ function buildV1ResourceStreamUrl(info, resource) {
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
if (uid.trim() !== '') return buildStreamUrl(uid.trim())
// Fallback for older resource shapes.
// In some memo payloads, the uid may appear as `name` directly.
// Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename.
if (isProbablyUid(name)) return buildStreamUrl(name.trim())
// Legacy versions (e.g. v0.18) may only expose numeric `id` without `uid/name`.
const idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
@@ -550,11 +555,6 @@ function buildV1ResourceStreamUrl(info, resource) {
: ''
if (id) return buildStreamUrl(id)
// Fallback for older resource shapes.
// In some memo payloads, the uid may appear as `name` directly.
// Example: name="ETU6hjuR..." should map to /o/r/:uid, not /file/:name/:filename.
if (isProbablyUid(name)) return buildStreamUrl(name.trim())
const fileId = resource.publicId || filename
if (name && fileId) return root + 'file/' + name + '/' + fileId
return ''