UNPKG

apache-autoindex-parse

Version:
43 lines (42 loc) 1.54 kB
import { i as FileEntry, n as DirectoryEntry, t as AutoIndexFormat } from "./index-CbQgiR6n.js"; //#region src/traverse.d.ts interface TraverseOptions { /** * Optional format specification of the auto-index page (will be inferred if not provided) * @default undefined */ format?: AutoIndexFormat; /** * Optional extra headers to include in the request * @default {} */ extraHeaders?: Record<string, string>; /** * Optional signal to abort the fetch request * @default undefined */ abortSignal?: AbortSignal; } type TraverseEntry = FileEntry | DirectoryEntry & { children: TraverseEntry[]; }; /** * Recursively traverses an Apache autoindex directory structure. * * This function fetches the HTML content from the provided URL, parses it to extract directory entries, * and then recursively traverses any subdirectories found. * * @param {string} rootUrl - The URL of the Apache autoindex directory to traverse * @param {TraverseOptions?} options - Optional configuration for the traversal process * @returns {Promise<TraverseEntry[]>} A promise that resolves to a RootEntry object representing the directory structure, or null if parsing failed * * @example * ```typescript * import { traverse } from 'apache-autoindex-parse/traverse'; * * const directoryStructure = await traverse('https://example.com/files'); * ``` */ declare function traverse(rootUrl: string, options?: TraverseOptions): Promise<TraverseEntry[]>; //#endregion export { TraverseEntry, TraverseOptions, traverse };