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

  1. Inspect the actual href value from the index page to understand the new URL format.
  2. Update the regex `/ (\d{6})\/(\d{2})\/node_\d+\.html/` in getIssueDate to match the new pattern.
  3. Pass a specific date in YYYYMMDD format to bypass the auto-detection: `/fjdaily/20260316`.
  4. 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

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

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/3cd498b2260d6ca4. Report an issue: GitHub.