mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
fix(frontend): give the embed snippet somewhere to paste.
The result screen ended at the snippet and a copy button. GitHub only renders a profile README from the repo named exactly after the account, and 15 of 23 arrivals did not have that repo, so the copy button was a dead end for most people. Add two links under the snippet: open the README, or create the repo. Also serve a placeholder card instead of a JSON 400 when someone pastes the README snippet without swapping YOUR_USERNAME for their own name, and show a live example card in the README. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BwMoSbmK77Ph7XaV5YnAdS
This commit is contained in:
@@ -458,6 +458,20 @@ def test_data_unknown_user_enrolls_when_under_both_caps(client, monkeypatch):
|
||||
assert dbmod.get_settings("testuser") is not None
|
||||
|
||||
|
||||
# ---- README snippet pasted without substituting the username ----
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["YOUR_USERNAME", "your_username", "yourusername", "username"])
|
||||
def test_unsubstituted_placeholder_returns_card_not_400(client, name):
|
||||
"""The README snippet uses YOUR_USERNAME. People paste it as-is, which
|
||||
renders a broken image on their profile. Serve instructions instead."""
|
||||
r = client.get(f"/api/{name}")
|
||||
assert r.status_code == 200
|
||||
assert r.mimetype == "image/svg+xml"
|
||||
assert r.headers["X-Widget-Status"] == "unsubstituted"
|
||||
assert b"Replace YOUR_USERNAME" in r.data
|
||||
|
||||
|
||||
# ---- /api/top-langs compat shim for upstream github-readme-stats URLs ----
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user