mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 22:37:29 +00:00
Ignore malformed feed probe candidates (#43)
Co-authored-by: Codex Microtask Operator <codex-microtask@example.com>
This commit is contained in:
parent
fbf4d76372
commit
ffefd364ce
2 changed files with 19 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ import { dedupeFeeds } from "./dedupe.js";
|
|||
import { discoverFeeds } from "./discovery.js";
|
||||
import { parseFeedDocument } from "./feed-parsing.js";
|
||||
import { renderDiscoveryOutput } from "./output/index.js";
|
||||
import { WebCandidateFeedProbeProvider } from "./providers/web-feed-probe.js";
|
||||
import { extractAlternateFeedLinks } from "./probe-site.js";
|
||||
import { scoreFeed } from "./scoring.js";
|
||||
import type { DiscoveredFeed, FeedDiscoveryProvider } from "./types.js";
|
||||
|
|
@ -64,6 +65,23 @@ describe("site probing helpers", () => {
|
|||
await expect(assertSafeHttpUrl("http://[::ffff:192.168.1.10]/feed")).rejects.toThrow(/Blocked internal/);
|
||||
await expect(assertSafeHttpUrl("file:///etc/passwd")).rejects.toThrow(/Unsupported URL protocol/);
|
||||
});
|
||||
|
||||
it("ignores malformed configured candidate URLs", async () => {
|
||||
const provider = new WebCandidateFeedProbeProvider({
|
||||
cacheTtlSeconds: 60,
|
||||
maxProviders: 1,
|
||||
maxProbes: 1,
|
||||
requestTimeoutMs: 10,
|
||||
maxBodyBytes: 1024,
|
||||
userAgent: "test",
|
||||
opmlPaths: [],
|
||||
candidateUrls: ["not-a-url|micro"],
|
||||
podcastIndexApiKey: undefined,
|
||||
podcastIndexApiSecret: undefined
|
||||
});
|
||||
|
||||
await expect(provider.search({ q: "micro" })).resolves.toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("scoring, dedupe, and output", () => {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function candidateUrls(query: FeedDiscoveryQuery, configured: string[]) {
|
|||
|
||||
for (const entry of configured) {
|
||||
const [url, ...keywords] = entry.split("|").map((part) => part.trim());
|
||||
if (!url) {
|
||||
if (!/^https?:\/\//i.test(url)) {
|
||||
continue;
|
||||
}
|
||||
if (keywords.length === 0 || keywords.some((keyword) => query.q.toLowerCase().includes(keyword.toLowerCase()))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue