Skip to content

fix(tools/search): apply exclude paths filter in crawl-based HTML search#52

Open
ericvangeem wants to merge 1 commit into
aemsites:mainfrom
ericvangeem:bugfix/exclude-paths-html-search
Open

fix(tools/search): apply exclude paths filter in crawl-based HTML search#52
ericvangeem wants to merge 1 commit into
aemsites:mainfrom
ericvangeem:bugfix/exclude-paths-html-search

Conversation

@ericvangeem

Copy link
Copy Markdown

Summary

Fixes the Exclude Paths configuration field so it correctly skips paths during HTML content searches.

Problem

The exclude-paths check only existed inside fetchFiles(), but the main HTML search bypasses fetchFiles() entirely — it uses DA's crawl() function with a processItem callback that never read the exclude-paths input. As a result, excluded paths were silently ignored.

The JSON file search branch calls fetchFilesForJson() directly and correctly honoured exclusions. Only the HTML crawl path was affected.

Closes #51

Fix

Added the same exclude-paths guard from fetchFiles() inside the processItem callback, immediately after the .html extension check:

const excludePathsInput = document.getElementById('exclude-paths')?.value?.trim() || '';
if (excludePathsInput) {
  const excludePaths = excludePathsInput.split(',').map((p) => p.trim());
  const isExcluded = excludePaths.some((excludePath) => {
    if (excludePath.startsWith('/')) return item.path.includes(excludePath);
    return item.path.includes(`/${excludePath}`);
  });
  if (isExcluded) return;
}

Testing

  1. Enter a valid org/site
  2. Add a folder path to Exclude Paths (e.g. /drafts)
  3. Run a search — files under that path should no longer appear in results
  4. Verify JSON file search and blank page search are unaffected

The exclude-paths check only existed in fetchFiles(), which is bypassed
when the main HTML search uses DA's crawl() function. Added the same
filter to the processItem callback so excluded paths are honored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude Paths filter not applied when searching HTML files

1 participant