Skip to content

Documentation / base / HttpDirectoryReaderContext

Interface: HttpDirectoryReaderContext

Defined in: libs/base/src/vfs/readers/reader.ts:11

Context utilities provided to an HttpDirectoryReader.

A reader implementation uses these helpers to fetch remote resources, resolve/normalize paths, and infer MIME types without depending on the VFS internals.

Properties

fetch

fetch: (url, init?) => Promise<Response>

Defined in: libs/base/src/vfs/readers/reader.ts:22

Fetch helper with the same signature as window.fetch, usually wrapped with timeouts/headers/credentials by the hosting VFS.

Implementations should use this instead of calling fetch directly.

Parameters

url

string

Absolute URL or path to fetch.

init?

RequestInit

Optional fetch initialization options.

Returns

Promise<Response>

A promise that resolves to the HTTP response.


toURL

toURL: (path) => string

Defined in: libs/base/src/vfs/readers/reader.ts:31

Converts a VFS path to an absolute URL that can be fetched.

Data URIs and object URLs should pass through unchanged.

Parameters

path

string

VFS path or URL-like string.

Returns

string

An absolute URL string.


normalizePath

normalizePath: (path) => string

Defined in: libs/base/src/vfs/readers/reader.ts:41

Normalizes a VFS path into canonical form.

Readers should use this to sanitize incoming paths and to build stable FileMetadata.path values.

Parameters

path

string

Input path.

Returns

string

Normalized path (typically absolute, POSIX style).


joinPath

joinPath: (...parts) => string

Defined in: libs/base/src/vfs/readers/reader.ts:48

Joins multiple path segments and normalizes the result.

Parameters

parts

...string[]

Path segments in order.

Returns

string

A normalized joined path.


guessMimeType

guessMimeType: (name) => string

Defined in: libs/base/src/vfs/readers/reader.ts:55

Best-effort MIME type inference based on a file name or path.

Parameters

name

string

File name or full path.

Returns

string

A MIME type string if known, otherwise undefined.

Released under the MIT License.