Fix additional URLs (#752)

This commit is contained in:
sua yoo 2023-04-05 20:11:09 -07:00 committed by GitHub
parent 91c2c1ad62
commit 80bc4a3eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -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`
<ul>
${additionalUrlList.map((url) => html`<li>${url}</li>`)}
${additionalUrlList.map(
(seed) =>
html`<li>${typeof seed === "string" ? seed : seed.url}</li>`
)}
</ul>
`
: msg("None"),

View File

@ -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";

View File

@ -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;
};