forked from claw/flaskpaste
routes: fix ruff formatting
This commit is contained in:
@@ -575,15 +575,11 @@ def validate_target_url(url: str) -> Response | None:
|
|||||||
"""Validate target URL for shortening. Returns error response or None if valid."""
|
"""Validate target URL for shortening. Returns error response or None if valid."""
|
||||||
max_length = current_app.config["SHORT_URL_MAX_LENGTH"]
|
max_length = current_app.config["SHORT_URL_MAX_LENGTH"]
|
||||||
if len(url) > max_length:
|
if len(url) > max_length:
|
||||||
return error_response(
|
return error_response("URL too long", 400, max_length=max_length, length=len(url))
|
||||||
"URL too long", 400, max_length=max_length, length=len(url)
|
|
||||||
)
|
|
||||||
|
|
||||||
parsed = urlparse(url)
|
parsed = urlparse(url)
|
||||||
if parsed.scheme not in ALLOWED_URL_SCHEMES:
|
if parsed.scheme not in ALLOWED_URL_SCHEMES:
|
||||||
return error_response(
|
return error_response("Invalid URL scheme", 400, allowed=list(ALLOWED_URL_SCHEMES))
|
||||||
"Invalid URL scheme", 400, allowed=list(ALLOWED_URL_SCHEMES)
|
|
||||||
)
|
|
||||||
if not parsed.netloc:
|
if not parsed.netloc:
|
||||||
return error_response("Invalid URL: missing host", 400)
|
return error_response("Invalid URL: missing host", 400)
|
||||||
|
|
||||||
@@ -2233,13 +2229,15 @@ class ShortURLsListView(MethodView):
|
|||||||
entry["expires_at"] = row["expires_at"]
|
entry["expires_at"] = row["expires_at"]
|
||||||
urls.append(entry)
|
urls.append(entry)
|
||||||
|
|
||||||
return json_response({
|
return json_response(
|
||||||
|
{
|
||||||
"urls": urls,
|
"urls": urls,
|
||||||
"count": len(urls),
|
"count": len(urls),
|
||||||
"total": total,
|
"total": total,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
"offset": offset,
|
"offset": offset,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user