Skip to content

lightgun-poc / lib/assets / diskAssets

Function: diskAssets() ​

diskAssets(dir): AssetSource

Defined in: lib/assets.ts:42

Serves files from a directory, refusing anything that escapes it.

Two layers: safeResolve rejects traversal in the requested name, and because dir itself can come from the CLI (--public), the canonical path of the file is then required to stay inside the canonical directory before it is read (path-injection guard; also refuses symlinks pointing elsewhere).

Parameters ​

dir ​

string

Returns ​

AssetSource

Released under the MIT License.