mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-08-22 16:31:40 +09:00
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:
+5
-5
@@ -516,6 +516,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)
|
||||
@@ -525,11 +530,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 ''
|
||||
|
||||
Reference in New Issue
Block a user