Skip to content

Commit f6c1ffc

Browse files
committed
fix: constrain request path table cells
1 parent f873ff4 commit f6c1ffc

3 files changed

Lines changed: 79 additions & 5 deletions

File tree

DebugProbe.AspNetCore.Tests/Rendering/HtmlRendererTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using DebugProbe.AspNetCore.Internal.Rendering;
2+
using DebugProbe.AspNetCore.Internal.Resources;
23
using DebugProbe.AspNetCore.Models;
34

45
namespace DebugProbe.AspNetCore.Tests.Rendering;
@@ -26,6 +27,40 @@ public void Render_index_page_builds_page_with_entries()
2627
Assert.Contains("200", html);
2728
}
2829

30+
[Fact]
31+
public void Render_index_page_constrains_path_cell_and_preserves_full_path_title()
32+
{
33+
var path = "/" + new string('a', 240);
34+
var query = "?filter=" + new string('b', 120);
35+
var fullPath = path + query;
36+
37+
var html = HtmlRenderer.RenderIndexPage(
38+
[
39+
new DebugEntry
40+
{
41+
Id = "trace-1",
42+
Method = "GET",
43+
Path = path,
44+
Query = query,
45+
StatusCode = 200,
46+
Timestamp = new DateTimeOffset(2026, 1, 2, 3, 4, 5, TimeSpan.Zero)
47+
}
48+
]);
49+
50+
Assert.Contains($@"<td class=""request-path""><span class=""request-path-value"" title=""{fullPath}"">{fullPath}</span></td>", html);
51+
}
52+
53+
[Fact]
54+
public void Embedded_css_keeps_request_index_table_fixed_with_ellipsized_paths()
55+
{
56+
Assert.Contains("#requestTable", EmbeddedResources.Css);
57+
Assert.Contains("table-layout: fixed;", EmbeddedResources.Css);
58+
Assert.Contains(".request-path-value", EmbeddedResources.Css);
59+
Assert.Contains("overflow: hidden;", EmbeddedResources.Css);
60+
Assert.Contains("text-overflow: ellipsis;", EmbeddedResources.Css);
61+
Assert.Contains("white-space: nowrap;", EmbeddedResources.Css);
62+
}
63+
2964
[Fact]
3065
public void Details_page_renders_captured_values()
3166
{

DebugProbe.AspNetCore/Assets/css/debugprobe.css

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,30 @@ table {
429429
border-collapse: collapse;
430430
}
431431

432+
#requestTable {
433+
table-layout: fixed;
434+
}
435+
436+
#requestTable th:nth-child(1),
437+
#requestTable td:nth-child(1) {
438+
width: 80px;
439+
}
440+
441+
#requestTable th:nth-child(2),
442+
#requestTable td:nth-child(2) {
443+
width: 96px;
444+
}
445+
446+
#requestTable th:nth-child(4),
447+
#requestTable td:nth-child(4) {
448+
width: 92px;
449+
}
450+
451+
#requestTable th:nth-child(5),
452+
#requestTable td:nth-child(5) {
453+
width: 100px;
454+
}
455+
432456
.table-wrap {
433457
overflow-x: auto;
434458
background: #fff;
@@ -463,6 +487,18 @@ tbody tr:last-child td {
463487
cursor: pointer;
464488
}
465489

490+
.request-path {
491+
min-width: 0;
492+
}
493+
494+
.request-path-value {
495+
display: block;
496+
overflow: hidden;
497+
max-width: 100%;
498+
text-overflow: ellipsis;
499+
white-space: nowrap;
500+
}
501+
466502
.method-pill {
467503
display: inline-flex;
468504
min-width: 60px;
@@ -1092,4 +1128,3 @@ pre {
10921128
background: #4a1717;
10931129
color: #ff8a8a !important;
10941130
}
1095-

DebugProbe.AspNetCore/Internal/Rendering/HtmlRenderer.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,23 @@ public static string RenderIndexPage(List<DebugEntry> items)
2626
{
2727
const int slowRequestThresholdMs = 1000;
2828

29-
var rows = string.Join("", items.Select(x => $@"
29+
var rows = string.Join("", items.Select(x =>
30+
{
31+
var pathWithQuery = string.IsNullOrEmpty(x.Query) ? x.Path : $"{x.Path}{x.Query}";
32+
33+
return $@"
3034
<tr data-url=""/debug/{Encode(x.Id)}""
3135
data-method=""{Encode(x.Method)}""
3236
data-status-family=""{x.StatusCode / 100}""
3337
data-search=""{Encode($"{x.Id} {x.Method} {x.Path} {x.Query} {x.StatusCode}")}""
3438
class=""clickable-row"">
3539
<td>{x.Timestamp:HH:mm:ss}</td>
3640
<td><span class=""method-pill"">{Encode(x.Method)}</span></td>
37-
<td>{Encode(string.IsNullOrEmpty(x.Query) ? x.Path : $"{x.Path}{x.Query}")}</td>
41+
<td class=""request-path""><span class=""request-path-value"" title=""{Encode(pathWithQuery)}"">{Encode(pathWithQuery)}</span></td>
3842
<td><span class=""status {GetStatusClass(x.StatusCode)}"">{x.StatusCode}</span></td>
3943
<td>{x.DurationMs} ms</td>
40-
</tr>"
41-
));
44+
</tr>";
45+
}));
4246

4347
if (string.IsNullOrEmpty(rows))
4448
rows = "<tr class='empty-row'><td colspan='5'>No data</td></tr>";

0 commit comments

Comments
 (0)