Skip to content

Commit

Permalink
request type based on mimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoventura committed Dec 6, 2024
1 parent 9b2e439 commit 8008d4e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/components/WebLogView/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Box, Table, Text } from '@radix-ui/themes'
import { Box, Table } from '@radix-ui/themes'

import { ProxyData, ProxyDataWithMatches } from '@/types'

import { MethodBadge } from '../MethodBadge'
import { ResponseStatusBadge } from '../ResponseStatusBadge'
import { TableCellWithTooltip } from '../TableCellWithTooltip'
import { HighlightedText } from '../HighlightedText'
import { isNonStaticAssetResponse } from '@/utils/staticAssets'
import { getRequestType } from './WebLogView.utils'

interface RowProps {
data: ProxyDataWithMatches
Expand Down Expand Up @@ -54,11 +54,7 @@ export function Row({ data, isSelected, onSelectRequest }: RowProps) {
/>
</ResponseStatusBadge>
</Table.Cell>
<Table.Cell>
<Text size="1">
{isNonStaticAssetResponse(data) ? 'Dynamic' : 'Static'}
</Text>
</Table.Cell>
<TableCellWithTooltip>{getRequestType(data)}</TableCellWithTooltip>
<TableCellWithTooltip>
<HighlightedText text={data.request.host} matches={data.matches} />
</TableCellWithTooltip>
Expand Down
2 changes: 1 addition & 1 deletion src/components/WebLogView/WebLogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function RequestList({
<Table.Row>
<Table.ColumnHeaderCell width="70px">Method</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="60px">Status</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="70px">Type</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="80px">Type</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="20%">Host</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="80%">Path</Table.ColumnHeaderCell>
</Table.Row>
Expand Down
11 changes: 11 additions & 0 deletions src/components/WebLogView/WebLogView.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GroupedProxyData, ProxyData } from '@/types'
import { getContentType } from '@/utils/headers'
import { isNonStaticAssetResponse } from '@/utils/staticAssets'

export function removeQueryStringFromUrl(url: string) {
return url.split('?')[0]
Expand All @@ -20,3 +22,12 @@ export function isGroupedProxyData(
): data is GroupedProxyData {
return !Array.isArray(data)
}

export function getRequestType(data: ProxyData) {
if (isNonStaticAssetResponse(data)) {
return 'fetch'
}

const mimeType = getContentType(data.response?.headers ?? [])
return mimeType ? mimeType.split('/')[1] : 'unknown'
}

0 comments on commit 8008d4e

Please sign in to comment.