DIYgod/RSSHub · error · Error
Failed to parse the latest Fujian Daily edition date.
Error message
Failed to parse the latest Fujian Daily edition date.
What it means
Thrown by the Fjdaily route when the latest edition's link href was successfully found but does not match the expected URL pattern `/(\d{6})\/(\d{2})\/node_\d+\.html/`. The route expects a path like `202603/16/node_01.html` (6-digit yearMonth, 2-digit day, node filename). If the site changed its URL scheme, the regex match fails and yearMonth/day are undefined.
Source
Thrown at lib/routes/fjdaily/index.ts:112
return {
yearMonth: date.slice(0, 6),
day: date.slice(6, 8),
};
}
const indexResponse = await got(`${ROOT_URL}/pc/col/index.html`);
const $ = load(indexResponse.data);
const latestPath = $('#list li:first-child a').attr('href');
if (!latestPath) {
throw new Error('Failed to locate the latest Fujian Daily edition.');
}
const [, yearMonth, day] = latestPath.match(/(\d{6})\/(\d{2})\/node_\d+\.html/) ?? [];
if (!yearMonth || !day) {
throw new Error('Failed to parse the latest Fujian Daily edition date.');
}
return {
yearMonth,
day,
};
};
export const route: Route = {
path: '/:date?',
categories: ['traditional-media'],
example: '/fjdaily/20260316',
parameters: { date: '日期,格式为 `YYYYMMDD`,留空时抓取当天全部版面,例如 `20260316`' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,View on GitHub (pinned to bed535e087)
Solutions
- Inspect the actual href value from the index page to understand the new URL format.
- Update the regex `/ (\d{6})\/(\d{2})\/node_\d+\.html/` in getIssueDate to match the new pattern.
- Pass a specific date in YYYYMMDD format to bypass the auto-detection: `/fjdaily/20260316`.
- Log `latestPath` to see the exact URL being parsed.
Example fix
// before
const [, yearMonth, day] = latestPath.match(/(\d{6})\/(\d{2})\/node_\d+\.html/) ?? [];
// after — support both old and new URL formats
const match = latestPath.match(/(\d{6})\/(\d{2})\/node_\d+\.html/)
?? latestPath.match(/(\d{4})\/(\d{2})\/(\d{2})\/node_\d+\.html/);
const yearMonth = match ? (match[1].length === 6 ? match[1] : match[1] + match[2]) : undefined;
const day = match ? (match[1].length === 6 ? match[2] : match[3]) : undefined; Defensive patterns
Strategy: fallback
Validate before calling
function parseEditionPath(href: string): { yearMonth: string; day: string } {
// Try multiple URL patterns
const patterns = [
/(?<ym>\d{6})\/(?<day>\d{2})\/node_\d+\.html/,
/(?<year>\d{4})\/(?<month>\d{2})\/(?<day>\d{2})\/node_\d+\.html/,
];
for (const p of patterns) {
const m = href.match(p);
if (m?.groups) {
const ym = m.groups.ym ?? m.groups.year + m.groups.month;
return { yearMonth: ym, day: m.groups.day };
}
}
throw new Error(`Unrecognized edition URL format: ${href}`);
} Type guard
function matchesEditionUrlFormat(href: string): boolean {
return /\d{6}\/\d{2}\/node_\d+\.html/.test(href)
|| /\d{4}\/\d{2}\/\d{2}\/node_\d+\.html/.test(href);
} Try / catch
const match = latestPath.match(/(\d{6})\/(\d{2})\/node_\d+\.html/);
if (!match) {
// Fallback: try to extract any date-like segments
const fallback = latestPath.match(/(\d{4})(\d{2})\/(\d{2})/);
if (fallback) {
yearMonth = fallback[1] + fallback[2];
day = fallback[3];
} else {
throw new Error(`Cannot parse edition date from URL: ${latestPath}`);
}
} Prevention
- Pass an explicit date (YYYYMMDD) to bypass URL parsing entirely.
- Support multiple URL format patterns to handle CMS migrations gracefully.
- Log the actual href value when parsing fails for quick diagnosis.
- Monitor the Fujian Daily URL scheme after site updates.
When it happens
Trigger: The Fujian Daily site changes its URL structure — e.g., from `202603/16/node_01.html` to `2026/03/16/node_01.html` (different digit grouping), or to a UUID-based path, or to a query-parameter-based URL. The href is found but its format no longer matches the regex.
Common situations: CMS migration that changes the URL routing scheme. The index page links to a different page format during special editions (holiday editions, supplements). A relative URL that resolves differently than expected.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to locate the latest Fujian Daily edition.
- No articles were found for ${yearMonth}${day}.
- this route is empty, please check the original site or <a hr
- Unknown type: ${item.type}
- Comic Not Found - ${name}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/3cd498b2260d6ca4.
Report an issue: GitHub.