From 80bc4a3eb936f9142feae9a66eb8209581de296c Mon Sep 17 00:00:00 2001 From: sua yoo Date: Wed, 5 Apr 2023 20:11:09 -0700 Subject: [PATCH] Fix additional URLs (#752) --- frontend/src/components/config-details.ts | 12 ++++++++---- frontend/src/pages/org/workflow-editor.ts | 8 ++++---- frontend/src/types/crawler.ts | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/config-details.ts b/frontend/src/components/config-details.ts index 92754da0..e2e781f4 100644 --- a/frontend/src/components/config-details.ts +++ b/frontend/src/components/config-details.ts @@ -267,9 +267,10 @@ export class ConfigDetails extends LiteElement { const crawlConfig = this.crawlConfig!; const seedsConfig = crawlConfig.config; const additionalUrlList = seedsConfig.seeds.slice(1); - const primarySeedConfig: SeedConfig | Seed = seedsConfig; - const primarySeedUrl = seedsConfig.seeds[0].url; - const includeUrlList = primarySeedConfig.include || seedsConfig.include; + const primarySeedConfig: SeedConfig | Seed = seedsConfig.seeds[0]; + const primarySeedUrl = primarySeedConfig.url; + const includeUrlList = + primarySeedConfig.include || seedsConfig.include || []; return html` ${this.renderSetting(msg("Primary Seed URL"), primarySeedUrl, true)} ${this.renderSetting( @@ -303,7 +304,10 @@ export class ConfigDetails extends LiteElement { additionalUrlList?.length ? html` ` : msg("None"), diff --git a/frontend/src/pages/org/workflow-editor.ts b/frontend/src/pages/org/workflow-editor.ts index 3b688169..42294fdb 100644 --- a/frontend/src/pages/org/workflow-editor.ts +++ b/frontend/src/pages/org/workflow-editor.ts @@ -195,6 +195,8 @@ const urlListToArray = flow( (str: string) => (str.length ? str.trim().split(/\s+/g) : []), trimArray ); +const mapSeedToUrl = (arr: Seed[]) => + arr.map((seed) => (typeof seed === "string" ? seed : seed.url)); const DEFAULT_BEHAVIORS = [ "autoscroll", "autoplay", @@ -428,13 +430,11 @@ export class CrawlConfigEditor extends LiteElement { } const additionalSeeds = seeds.slice(1); if (additionalSeeds.length) { - formState.urlList = additionalSeeds.join("\n"); + formState.urlList = mapSeedToUrl(additionalSeeds).join("\n"); } } else { // Treat "custom" like URL list - formState.urlList = seeds - .map((seed) => (typeof seed === "string" ? seed : seed.url)) - .join("\n"); + formState.urlList = mapSeedToUrl(seeds).join("\n"); if (this.initialWorkflow.jobType === "custom") { formState.scopeType = seedsConfig.scopeType || "page"; diff --git a/frontend/src/types/crawler.ts b/frontend/src/types/crawler.ts index a5303c62..6007e6aa 100644 --- a/frontend/src/types/crawler.ts +++ b/frontend/src/types/crawler.ts @@ -10,8 +10,8 @@ type ScopeType = export type Seed = { url: string; scopeType: ScopeType; - include?: string[]; - exclude?: string[]; + include?: string[] | null; + exclude?: string[] | null; limit?: number | null; extraHops?: number | null; };