mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 17:54:58 +00:00
fix(browser): revalidate upload paths at use time
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
resolveExistingPathsWithinRoot,
|
||||
resolvePathsWithinRoot,
|
||||
resolvePathWithinRoot,
|
||||
resolveStrictExistingPathsWithinRoot,
|
||||
} from "./paths.js";
|
||||
|
||||
async function createFixtureRoot(): Promise<{ baseDir: string; uploadsDir: string }> {
|
||||
@@ -194,6 +195,29 @@ describe("resolveExistingPathsWithinRoot", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("resolveStrictExistingPathsWithinRoot", () => {
|
||||
function expectInvalidResult(
|
||||
result: Awaited<ReturnType<typeof resolveStrictExistingPathsWithinRoot>>,
|
||||
expectedSnippet: string,
|
||||
) {
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) {
|
||||
expect(result.error).toContain(expectedSnippet);
|
||||
}
|
||||
}
|
||||
|
||||
it("rejects missing files instead of returning lexical fallbacks", async () => {
|
||||
await withFixtureRoot(async ({ uploadsDir }) => {
|
||||
const result = await resolveStrictExistingPathsWithinRoot({
|
||||
rootDir: uploadsDir,
|
||||
requestedPaths: ["missing.txt"],
|
||||
scopeLabel: "uploads directory",
|
||||
});
|
||||
expectInvalidResult(result, "regular non-symlink file");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolvePathWithinRoot", () => {
|
||||
it("uses default file name when requested path is blank", () => {
|
||||
const result = resolvePathWithinRoot({
|
||||
|
||||
Reference in New Issue
Block a user