release: v1.2.2 — 双域名配置与 Host 隔离修复
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s

修复设置页误清空管理域、配置与生效 URL 混淆及第三 Host 绕过隔离;加固 Settings API 与中间件,并更新文档站。
This commit is contained in:
O96u committed 2026-08-30 10:57:26 +08:00
1 parent 6c6766221b
commit c9c34515dd
36 files changed
+2578 -180

No files matched your search

+24 -3
View File
@@ -1,9 +1,30 @@
import { basename } from 'node:path'
import { DEFAULT_FOLDER, validateImageKey } from './image-key'
/** 对外 URL 路径:可选隐藏目录前缀(输出纯文件名) */
/** 存储 key → 对外 URL 路径(不含域名) */
export function storageKeyToPublicPath(key: string): string {
const prefix = `${DEFAULT_FOLDER}/`
if (key.startsWith(prefix)) return key.slice(prefix.length)
return key
}
/**
* 对外 URL 路径:
* - hideFolder=true:仅文件名(img.com/a8K3xP.webp)
* - hideFolder=false:去掉内部 images/ 前缀(img.com/2026/08/a.webp)
*/
export function toPublicImagePath(key: string, hideFolder: boolean): string {
if (!hideFolder) return key
return basename(key)
if (hideFolder) return basename(key)
return storageKeyToPublicPath(key)
}
/** 公开相对路径 → 存储 key;legacy 完整 key(含 images/)仍接受 */
export function toStorageKeyFromPublicPath(publicPath: string): string | null {
const raw = publicPath.replace(/^\/+/, '')
if (!raw) return null
if (validateImageKey(raw)) return raw
const candidate = `${DEFAULT_FOLDER}/${raw}`
return validateImageKey(candidate) ? candidate : null
}
const HIDDEN_DATE_PATH_PATTERN