mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-23 02:54:58 +01:00
* 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…
33 lines
935 B
TypeScript
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>
|
|
);
|
|
}
|