Files
menav/test/favicon-v2-drop-404-icon.node-test.js
rbetree d19c4da51d fix(icons): faviconV2 加入 drop_404_icon=true 参数避免404占位图以触发回退
- helpers:faviconV2Url / faviconFallbackUrl 统一追加 drop_404_icon=true
- runtime:新增站点的 faviconV2 com/cn URL 同步追加该参数
- docs:更新模板与 helper 文档示例
- test:新增用例防止参数回归
2026-01-16 22:52:39 +08:00

33 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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'
);
});