fix(icons): faviconV2 加入 drop_404_icon=true 参数避免404占位图以触发回退
- helpers:faviconV2Url / faviconFallbackUrl 统一追加 drop_404_icon=true - runtime:新增站点的 faviconV2 com/cn URL 同步追加该参数 - docs:更新模板与 helper 文档示例 - test:新增用例防止参数回归
This commit is contained in:
32
test/favicon-v2-drop-404-icon.node-test.js
Normal file
32
test/favicon-v2-drop-404-icon.node-test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const { faviconV2Url, faviconFallbackUrl } = require('../src/helpers/utils');
|
||||
|
||||
test('faviconV2:应追加 drop_404_icon=true 以避免返回占位图', () => {
|
||||
const optionsCom = { data: { root: { icons: { region: 'com' } } } };
|
||||
const optionsCn = { data: { root: { icons: { region: 'cn' } } } };
|
||||
|
||||
const url = 'https://example.com';
|
||||
|
||||
const com = faviconV2Url(url, optionsCom);
|
||||
const cn = faviconV2Url(url, optionsCn);
|
||||
const fallbackCom = faviconFallbackUrl(url, optionsCom);
|
||||
const fallbackCn = faviconFallbackUrl(url, optionsCn);
|
||||
|
||||
for (const out of [com, cn, fallbackCom, fallbackCn]) {
|
||||
assert.ok(out.includes('drop_404_icon=true'), '生成的 URL 应包含 drop_404_icon=true');
|
||||
}
|
||||
});
|
||||
|
||||
test('运行时新增站点:faviconV2 URL 也应包含 drop_404_icon=true', () => {
|
||||
const repoRoot = path.resolve(__dirname, '..');
|
||||
const runtimePath = path.join(repoRoot, 'src', 'runtime', 'menav', 'addElement.js');
|
||||
const content = fs.readFileSync(runtimePath, 'utf8');
|
||||
assert.ok(
|
||||
content.includes('drop_404_icon=true'),
|
||||
'src/runtime/menav/addElement.js 应追加 drop_404_icon=true'
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user