openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1 kB
JavaScript
import{c as resolveUserPath}from"./home-dir-DEN5DisQ.mjs";import{s as relativePathEscapesRoot}from"./path-guards-DGttsOJI.mjs";import{r as parseInboundMediaUri}from"./inbound-media-uri-COqbYFEq.mjs";import{t as getMediaDir}from"./store-path-CwOJyIi3.mjs";import path from"node:path";import{safeFileURLToPath}from"@openclaw/fs-safe/advanced";
//!src/media/inbound-media-path.ts
function maybeLocalPathFromSource(e){if(/^file:/i.test(e))try{return safeFileURLToPath(e)}catch{return null}if(e.startsWith(`~`))return resolveUserPath(e);if(path.isAbsolute(e))return e;return null}function buildInboundMediaUriFromPath(e){const t=maybeLocalPathFromSource(e.trim());if(!t)return;const n=path.resolve(getMediaDir(),`inbound`);const r=path.relative(n,path.resolve(t));if(!r||relativePathEscapesRoot(r)||r.includes(path.sep)||r.includes(`\\`))return;try{return parseInboundMediaUri(`media://inbound/${r}`)?.normalizedSource}catch{return}}export{maybeLocalPathFromSource as n,buildInboundMediaUriFromPath as t};