feat(polaris): import bookmarks and refine category scrolling

- 导入 29 条精选公开书签,排除重复与敏感入口
- 将滚动限制在分类页内层卡片区域,并适配窄屏
- 更新数据与页面测试
This commit is contained in:
2026-10-08 19:49:30 +08:00
parent 6641d181ab
commit e37cf9936e
7 changed files with 547 additions and 50 deletions
+31 -2
View File
@@ -27,9 +27,9 @@ describe("Polaris 静态数据", () => {
}
})
it("包含 16 条合法链接且分类引用均存在", () => {
it("包含 45 条合法链接且分类引用均存在", () => {
const categoryIds = new Set(categories.map(({ id }) => id))
expect(links).toHaveLength(16)
expect(links).toHaveLength(45)
expect(hasUniqueValues(links.map(({ id }) => id))).toBe(true)
for (const link of links) {
@@ -86,4 +86,33 @@ describe("Polaris 静态数据", () => {
expect(Number.isFinite(settings.background.blur)).toBe(true)
expect(Number.isFinite(settings.background.overlay)).toBe(true)
})
describe("导入链接卫生检查", () => {
const normalizeUrl = (url: string) => url.replace(/\/+$/, "")
it("全部链接 URL 唯一(忽略末尾斜杠)", () => {
const urls = links.map(({ url }) => normalizeUrl(url))
expect(hasUniqueValues(urls)).toBe(true)
})
it("不包含本地或内网地址", () => {
for (const link of links) {
const { hostname } = new URL(link.url)
expect(hostname).toMatch(/^[\w.-]+$/)
expect(hostname).not.toBe("localhost")
expect(hostname).not.toMatch(/\.(local|lan|internal)$/)
expect(hostname).not.toMatch(
/^(127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.|0\.0\.0\.0)/,
)
}
})
it("不携带查询参数或片段,防止 sid/jumpuin 等会话标识混入", () => {
for (const link of links) {
const url = new URL(link.url)
expect([...url.searchParams.keys()]).toEqual([])
expect(url.hash).toBe("")
}
})
})
})