Files
yaak-mountain-loop/src-web/components/responseViewers/WebPageViewer.tsx
Gregory Schier eb3d1c409b Merge pull request #256
* Update environment model to get ready for request/folder environments

* Folder environments in UI

* Folder environments working

* Tweaks and fixes

* Tweak environment encryption UX

* Tweak environment encryption UX

* Address comments

* Update fn name

* Add tsc back to lint rules

* Update src-web/components/EnvironmentEditor.tsx

* Merge remote-tracking branch 'origin/folder-environments' into folder…
2025-09-21 07:54:26 -07:00

33 lines
935 B
TypeScript

import { useMemo } from 'react';
import { useResponseBodyText } from '../../hooks/useResponseBodyText';
import type { HttpResponse } from '@yaakapp-internal/models';
interface Props {
response: HttpResponse;
}
export function WebPageViewer({ response }: Props) {
const { url } = response;
const body = useResponseBodyText({ response, filter: null }).data ?? '';
const contentForIframe: string | undefined = useMemo(() => {
if (body.includes('<head>')) {
return body.replace(/<head>/gi, `<head><base href="${url}"/>`);
}
return body;
}, [url, body]);
return (
<div className="h-full pb-3">
<iframe
key={body ? 'has-body' : 'no-body'}
title="Yaak response preview"
srcDoc={contentForIframe}
sandbox="allow-scripts allow-forms"
referrerPolicy="no-referrer"
className="h-full w-full rounded border border-border-subtle"
/>
</div>
);
}