mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-08-23 00:41:39 +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:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
## 更新日志
|
## 更新日志
|
||||||
- 20260805 适配 Memos 0.29.x Attachment API,修复附件上传、绑定和预览地址
|
- 20260805 适配 Memos 0.29.x Attachment API,修复附件上传、绑定和预览地址;修复 0.20.x 图片预览 URL 错误使用 numeric id 的问题
|
||||||
- 20260425 新增德语/法语/西班牙语支持
|
- 20260425 新增德语/法语/西班牙语支持
|
||||||
- 20260423 优化 firefox 抖动问题和支持手机版,支持 edge 浏览器扩展
|
- 20260423 优化 firefox 抖动问题和支持手机版,支持 edge 浏览器扩展
|
||||||
- 20260422 调整发送设置,支持仅发送附件
|
- 20260422 调整发送设置,支持仅发送附件
|
||||||
|
|||||||
+5
-5
@@ -516,6 +516,11 @@ function buildV1ResourceStreamUrl(info, resource) {
|
|||||||
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
|
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
|
||||||
if (uid.trim() !== '') return buildStreamUrl(uid.trim())
|
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`.
|
// 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 idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id
|
||||||
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
|
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
|
||||||
@@ -525,11 +530,6 @@ function buildV1ResourceStreamUrl(info, resource) {
|
|||||||
: ''
|
: ''
|
||||||
if (id) return buildStreamUrl(id)
|
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
|
const fileId = resource.publicId || filename
|
||||||
if (name && fileId) return root + 'file/' + name + '/' + fileId
|
if (name && fileId) return root + 'file/' + name + '/' + fileId
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
+5
-5
@@ -516,6 +516,11 @@ function buildV1ResourceStreamUrl(info, resource) {
|
|||||||
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
|
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
|
||||||
if (uid.trim() !== '') return buildStreamUrl(uid.trim())
|
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`.
|
// 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 idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id
|
||||||
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
|
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
|
||||||
@@ -525,11 +530,6 @@ function buildV1ResourceStreamUrl(info, resource) {
|
|||||||
: ''
|
: ''
|
||||||
if (id) return buildStreamUrl(id)
|
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
|
const fileId = resource.publicId || filename
|
||||||
if (name && fileId) return root + 'file/' + name + '/' + fileId
|
if (name && fileId) return root + 'file/' + name + '/' + fileId
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
+5
-5
@@ -541,6 +541,11 @@ function buildV1ResourceStreamUrl(info, resource) {
|
|||||||
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
|
const uid = typeof uidRaw === 'string' ? uidRaw : uidRaw != null ? String(uidRaw) : ''
|
||||||
if (uid.trim() !== '') return buildStreamUrl(uid.trim())
|
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`.
|
// 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 idRaw = resource.id != null ? resource.id : resource.ID != null ? resource.ID : resource.Id
|
||||||
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
|
const id = typeof idRaw === 'number' && Number.isFinite(idRaw)
|
||||||
@@ -550,11 +555,6 @@ function buildV1ResourceStreamUrl(info, resource) {
|
|||||||
: ''
|
: ''
|
||||||
if (id) return buildStreamUrl(id)
|
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
|
const fileId = resource.publicId || filename
|
||||||
if (name && fileId) return root + 'file/' + name + '/' + fileId
|
if (name && fileId) return root + 'file/' + name + '/' + fileId
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
Reference in New Issue
Block a user