diff --git a/frontend/src/pages/org/workflow-editor.ts b/frontend/src/pages/org/workflow-editor.ts index 749a9e94..4570c77c 100644 --- a/frontend/src/pages/org/workflow-editor.ts +++ b/frontend/src/pages/org/workflow-editor.ts @@ -103,6 +103,8 @@ type FormState = { autoscrollBehavior: boolean; }; +const DEPTH_SUPPORTED_SCOPES = ["prefix", "host", "domain", "custom", "any"]; + const getDefaultProgressState = (hasConfigId = false): ProgressState => { let activeTab: StepName = "crawlSetup"; if (window.location.hash) { @@ -422,13 +424,15 @@ export class CrawlConfigEditor extends LiteElement { formState.primarySeedUrl = primarySeedConfig.url; } if ( - primarySeedConfig.scopeType === "custom" && primarySeedConfig.include?.length ) { formState.customIncludeUrlList = primarySeedConfig.include // Unescape regex .map((url) => url.replace(/(\\|\/\.\*)/g, "")) .join("\n"); + // if we have additional include URLs, set to "custom" scope here + // to indicate 'Custom Page Prefix' option + formState.scopeType = "custom"; } const additionalSeeds = seeds.slice(1); if (additionalSeeds.length) { @@ -1044,7 +1048,7 @@ https://example.com/path`} msg(`Tells the crawler which pages it can visit.`) )} ${when( - ["host", "domain", "custom", "any"].includes(this.formState.scopeType), + DEPTH_SUPPORTED_SCOPES.includes(this.formState.scopeType), () => html` ${this.renderFormCol(html` `${regexEscape(url)}\/.*`), + ...includeUrlList.map((url) => regexEscape(url)), ] : [], extraHops: this.formState.includeLinkedPages ? 1 : 0, }; - if ( - ["host", "domain", "custom", "any"].includes(this.formState.scopeType) - ) { + if (DEPTH_SUPPORTED_SCOPES.includes(this.formState.scopeType)) { primarySeed.depth = this.formState.maxScopeDepth; } const config = { seeds: [primarySeed, ...additionalSeedUrlList], - scopeType: additionalSeedUrlList.length - ? "page" - : this.formState.scopeType, + scopeType: this.formState.scopeType, }; return config; }