Skip to content

Commit 74d461a

Browse files
committed
handle case of iframe html in a subdir
1 parent 8cdcffc commit 74d461a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/packages/frontend/frame-editors/html-editor/iframe-html.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
change_filename_extension,
2222
is_different,
2323
list_alternatives,
24+
path_split,
2425
} from "@cocalc/util/misc";
2526
import { debounce } from "lodash";
2627
import { React, ReactDOM, Rendered, CSS } from "../../app-framework";
@@ -146,7 +147,13 @@ export const IFrameHTML: React.FC<Props> = React.memo((props: Props) => {
146147
// extra security and pointed in the right direction.
147148
// We can't just use <iframe src= since the backend 'raw files' server
148149
// just always forces a download of that, for security reasons.
149-
const extraHead = `<base href="${join(appBasePath, project_id)}/files/">
150+
const base = join(
151+
appBasePath,
152+
project_id,
153+
"files",
154+
encodeURIComponent(path_split(actual_path).head) + "/",
155+
);
156+
const extraHead = `<base href="${base}">
150157
<meta http-equiv="Content-Security-Policy" content="default-src * data: blob: 'unsafe-inline' 'unsafe-eval';
151158
script-src * data: blob: 'unsafe-inline' 'unsafe-eval';
152159
img-src * data: blob:;

0 commit comments

Comments
 (0)