mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-18 06:49:50 +02:00
Content type highlighting
This commit is contained in:
@@ -15,6 +15,7 @@ interface Response {
|
||||
status: string;
|
||||
elapsed: number;
|
||||
elapsed2: number;
|
||||
headers: Record<string, string>;
|
||||
}
|
||||
|
||||
function App() {
|
||||
@@ -27,6 +28,7 @@ function App() {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
const resp = (await invoke('send_request', { method, url })) as Response;
|
||||
console.log('RESP', resp);
|
||||
if (resp.body.includes('<head>')) {
|
||||
resp.body = resp.body.replace(/<head>/gi, `<head><base href="${resp.url}"/>`);
|
||||
}
|
||||
@@ -34,6 +36,8 @@ function App() {
|
||||
setResponseBody(resp);
|
||||
}
|
||||
|
||||
const contentType = responseBody?.headers['content-type']?.split(';')[0] ?? 'text/plain';
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
@@ -79,7 +83,7 @@ function App() {
|
||||
{responseBody?.elapsed2}ms
|
||||
</div>
|
||||
<Grid cols={2} rows={2} gap={1}>
|
||||
<Editor value={responseBody?.body} language="application/json" />
|
||||
<Editor value={responseBody?.body} contentType={contentType} />
|
||||
<div className="iframe-wrapper">
|
||||
<iframe
|
||||
title="Response preview"
|
||||
|
||||
Reference in New Issue
Block a user