apache-autoindex-parse
Version:
parse apache's autoindex html files
38 lines (35 loc) • 1.37 kB
text/typescript
import { AutoIndexFormat, RootEntry } from './index.cjs';
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;
}
/**
* 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<RootEntry | null>} A promise that resolves to a RootEntry object representing the directory structure, or null if parsing failed
*
* @example
* ```typescript
* const directoryStructure = await traverse('[https://example.com/files/](https://example.com/files/)');
* ```
*/
declare function traverse(rootUrl: string, options?: TraverseOptions): Promise<RootEntry | null>;
export { type TraverseOptions, traverse };