Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions plugins/english/noveldex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Noveldex implements Plugin.PluginBase {
name = 'NovelDex';
icon = 'src/en/noveldex/icon.png';
site = 'https://noveldex.io';
version = '1.0.0';
version = '1.0.1';
// Filter do take a lot of space
filters = {
sort: {
Expand Down Expand Up @@ -427,10 +427,29 @@ class Noveldex implements Plugin.PluginBase {
// For searching novels | Helpers for main function
private findClientId(rscText: string, componentName: string): string | null {
const escaped = componentName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const match = rscText.match(
new RegExp(`^([0-9a-fA-F]+):I\\[\\d+,\\[[^\\]]*\\],"${escaped}"\\]`, 'm'),

// 1) Inline form: <hex>:I[<mod>,[...],"ComponentName"]
// Capture groups: [1] = row id, [2] = module id
const direct = rscText.match(
new RegExp(
`^([0-9a-fA-F]+):I\\[(\\d+),\\[[^\\]]*\\],"${escaped}"\\]`,
'm',
),
);
if (direct) return direct[1];

// 2) Dedupe form: <hex>:"ComponentName" then <hex>:I[<mod>,[...],"$<hex>"]
const def = rscText.match(new RegExp(`^([0-9a-fA-F]+):"${escaped}"$`, 'm'));
if (!def) return null;

const ref = def[1];
const indirect = rscText.match(
new RegExp(
`^([0-9a-fA-F]+):I\\[(\\d+),\\[[^\\]]*\\],"\\$${ref}"\\]`,
'm',
),
);
return match ? match[1] : null;
return indirect ? indirect[1] : null; // or indirect[2]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Comment suggests the wrong id

// or indirect[2] suggests an incorrect alternative. That group holds the module id, while extractSeriesPage and extractBrowsePage need the row id to find a $L reference. Following this comment could break novel lists or details. Remove the trailing comment; the current return value is correct.

Suggested change
return indirect ? indirect[1] : null; // or indirect[2]
return indirect ? indirect[1] : null;

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

}

private findSeriesClientId(rscText: string): string | null {
Expand Down
Loading