MCPcopy
hub / github.com/freshframework/fresh / assertInDir

Function assertInDir

packages/fresh/src/utils.ts:5–17  ·  view source on GitHub ↗
(
  filePath: string,
  dir: string,
)

Source from the content-addressed store, hash-verified

3import { pathToFileUrl, relativeUrl } from "./file_url.ts";
4
5export function assertInDir(
6 filePath: string,
7 dir: string,
8): void {
9 let tmp = filePath;
10 if (!path.isAbsolute(tmp)) {
11 tmp = path.join(dir, filePath);
12 }
13
14 if (path.relative(dir, tmp).startsWith(".")) {
15 throw new Error(`Path "${tmp}" resolved outside of "${dir}"`);
16 }
17}
18
19/**
20 * Converts a file path to a valid JS export name.

Callers 2

addProcessedFileMethod · 0.90
flushMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected