MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / resolveStaticFilePath

Function resolveStaticFilePath

lib/http-server.js:20–42  ·  view source on GitHub ↗
(urlPath)

Source from the content-addressed store, hash-verified

18const WEB_ROOT = path.resolve(__dirname, '..', 'web');
19
20function resolveStaticFilePath(urlPath) {
21 let decodedPath;
22 try {
23 decodedPath = decodeURIComponent(urlPath || '/');
24 } catch {
25 return null;
26 }
27
28 const relativePath = decodedPath === '/'
29 ? 'index.html'
30 : decodedPath.replace(/^\/+/, '');
31 const filePath = path.resolve(WEB_ROOT, relativePath);
32 const relativeToRoot = path.relative(WEB_ROOT, filePath);
33
34 if (
35 relativeToRoot.startsWith('..') ||
36 path.isAbsolute(relativeToRoot)
37 ) {
38 return null;
39 }
40
41 return filePath;
42}
43
44function createHttpServer() {
45 return http.createServer((req, res) => {

Callers 2

createHttpServerFunction · 0.85
test-modules.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected