fix(api): normalize GitHub usernames to lowercase and update tests.

This commit is contained in:
shay
2026-07-19 21:01:40 -07:00
parent 0586f83a33
commit fe4bb4e87e
4 changed files with 62 additions and 0 deletions
+4
View File
@@ -11,6 +11,10 @@ from flask_compress import Compress
from . import analytics, cache as cache_mod, config
app = Flask(__name__)
# Tolerate stray trailing slashes on every route, matching the generator. A
# hand-copied embed URL like `/alice/` should resolve like `/alice` instead of
# Flask's default strict_slashes 404. Set before the route decorators run.
app.url_map.strict_slashes = False
Compress(app)
cache_ext = cache_mod.build_cache(app)
log = logging.getLogger("edge")
+11
View File
@@ -44,6 +44,17 @@ def test_origin_error_returns_503(client):
assert r.status_code == 503
@responses.activate
def test_trailing_slash_tolerated(client):
"""A hand-copied `/alice/` must resolve like `/alice`, not 404."""
responses.add(responses.GET, "http://gen:5002/api/alice",
body=b"<svg>ready</svg>", status=200,
headers={"X-Widget-Status": "ready", "Content-Type": "image/svg+xml"})
r = client.get("/alice/")
assert r.status_code == 200
assert r.data == b"<svg>ready</svg>"
def test_health(client):
r = client.get("/health")
assert r.status_code == 200