mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
fix(api): normalize GitHub usernames to lowercase and update tests.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user