web: friendly Paste ID not found page for missing pastes (#173)
Missing or expired paste IDs (and unknown routes) now render the main UI chrome with a 'Paste ID not found' message in a color-coded result card instead of a bare text/JSON 404. HTTP status stays 404. No inline scripts or styles; new CSS uses existing --err token and pill radii.
This commit is contained in:
@@ -299,3 +299,27 @@ func TestNotFound(t *testing.T) {
|
|||||||
t.Fatalf("expected 404, got %d", rec.Code)
|
t.Fatalf("expected 404, got %d", rec.Code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #173: a missing paste ID on the UI route (/p/{id}, i.e. /{id} HTML view)
|
||||||
|
// should render the main UI page with a friendly "Paste ID not found"
|
||||||
|
// message, not a bare text 404. Status stays 404.
|
||||||
|
func TestPasteViewNotFoundFriendly(t *testing.T) {
|
||||||
|
s := testServer(t)
|
||||||
|
h := s.routes()
|
||||||
|
req := httptest.NewRequest("GET", "/zzzzzz", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
h.ServeHTTP(rec, req)
|
||||||
|
if rec.Code != http.StatusNotFound {
|
||||||
|
t.Fatalf("expected 404 status, got %d", rec.Code)
|
||||||
|
}
|
||||||
|
body := rec.Body.String()
|
||||||
|
if !strings.Contains(body, "Paste ID not found") {
|
||||||
|
t.Fatalf("expected friendly message in body, got: %.200s", body)
|
||||||
|
}
|
||||||
|
if !strings.Contains(body, "<nav>") {
|
||||||
|
t.Fatalf("expected main UI chrome in body")
|
||||||
|
}
|
||||||
|
if strings.Contains(body, "404 page not found") {
|
||||||
|
t.Fatalf("body still contains bare Go 404 text")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -341,6 +341,9 @@ td a.slug.paste-name { background: none; padding: 0; border-radius: 0; font-fami
|
|||||||
}
|
}
|
||||||
.inner h1 { font-size: 29.2px; font-weight: 600; margin-bottom: 6px; }
|
.inner h1 { font-size: 29.2px; font-weight: 600; margin-bottom: 6px; }
|
||||||
.inner .sub { font-size: 22.4px; color: var(--muted-fg); margin-bottom: 20px; }
|
.inner .sub { font-size: 22.4px; color: var(--muted-fg); margin-bottom: 20px; }
|
||||||
|
/* #173: missing paste message box */
|
||||||
|
.notfound-err { color: var(--err); }
|
||||||
|
.notfound-card .btn { display: block; margin-top: 10px; }
|
||||||
.pwinput {
|
.pwinput {
|
||||||
width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
|
width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
|
||||||
background: var(--bg); color: var(--fg); font: inherit; font-size: 23.2px; outline: none; text-align: center;
|
background: var(--bg); color: var(--fg); font: inherit; font-size: 23.2px; outline: none; text-align: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user