An IDocumentLoader that fetches a remote URL and delegates parsing to the appropriate registered loader based on the response Content-Type.

Supported content types

Content-Type Delegates to
text/html HtmlLoader (registry)
application/pdf PdfLoader (registry)
Everything else Plain UTF-8 text

Example

const registry = new LoaderRegistry();
const urlLoader = new UrlLoader(registry);

// Register so the registry also dispatches URLs via canLoad checks.
// (Optional — UrlLoader can be used standalone too.)

if (urlLoader.canLoad('https://example.com/report.pdf')) {
const doc = await urlLoader.load('https://example.com/report.pdf');
console.log(doc.format); // 'pdf'
}

Implements

Implements

Constructors

Methods

Properties

Constructors

Methods

  • Returns true when source is a string that starts with http:// or https://.

    Buffer sources are always rejected — raw bytes cannot be a URL.

    Parameters

    • source: string | Buffer<ArrayBufferLike>

      Absolute file path, URL string, or raw bytes.

    Returns boolean

  • Fetch source over HTTP/HTTPS and return a LoadedDocument.

    The response body is buffered in memory and then handed to the appropriate sub-loader according to the Content-Type header:

    • text/html → fetched as text, passed to the HTML loader as a Buffer.
    • application/pdf → fetched as bytes, passed to the PDF loader as a Buffer.
    • Anything else → returned as plain text with format 'text' and source metadata set to the URL.

    Parameters

    • source: string | Buffer<ArrayBufferLike>

      HTTP/HTTPS URL string.

    • Optional options: LoadOptions

      Optional load hints forwarded to the delegated loader.

    Returns Promise<LoadedDocument>

    A promise resolving to the LoadedDocument.

    Throws

    When source is a Buffer (URLs must be strings).

    Throws

    When the HTTP request fails (network error or non-2xx status).

Properties

supportedExtensions: string[] = []

URLs have no file extension so this array is always empty.

Routing to this loader must be performed via canLoad rather than the registry's extension-based lookup.