MCPcopy
hub / github.com/vitejs/vite / isFileServingAllowed

Function isFileServingAllowed

packages/vite/src/node/server/middlewares/static.ts:257–271  ·  view source on GitHub ↗
(
  configOrUrl: ResolvedConfig | string,
  urlOrServer: string | ViteDevServer,
)

Source from the content-addressed store, hash-verified

255 server: ViteDevServer,
256): boolean
257export function isFileServingAllowed(
258 configOrUrl: ResolvedConfig | string,
259 urlOrServer: string | ViteDevServer,
260): boolean {
261 const config = (
262 typeof urlOrServer === 'string' ? configOrUrl : urlOrServer.config
263 ) as ResolvedConfig
264 const url = (
265 typeof urlOrServer === 'string' ? urlOrServer : configOrUrl
266 ) as string
267
268 if (!config.server.fs.strict) return true
269 const filePath = fsPathFromUrl(url)
270 return isFileLoadingAllowed(config, filePath)
271}
272
273/**
274 * Warning: parameters are not validated, only works with normalized absolute paths

Callers

nothing calls this directly

Calls 2

fsPathFromUrlFunction · 0.90
isFileLoadingAllowedFunction · 0.85

Tested by

no test coverage detected