Fix product slug: extract from URL path instead of g.post_slug
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 53s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 53s
App-level preprocessor pops slug then page_slug into g.post_slug,
overwriting the product slug with the page slug ("market"). Extract
the product slug directly from the request path after "/product/".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,9 +25,17 @@ def register():
|
||||
bp = Blueprint("product", __name__, url_prefix="/product/<slug>")
|
||||
@bp.url_value_preprocessor
|
||||
def pull_blog(endpoint, values):
|
||||
# App-level preprocessor pops "slug" into g.post_slug before this runs,
|
||||
# so values.get("slug") is None. Fall back to g.post_slug.
|
||||
g.product_slug = values.get("slug") or getattr(g, "post_slug", None)
|
||||
# App-level preprocessor pops both "slug" and "page_slug" into g.post_slug,
|
||||
# with page_slug overwriting slug. We need the original product slug which
|
||||
# the app preprocessor popped first — but it's gone. Instead, extract the
|
||||
# product slug from the request path: .../product/<slug>/...
|
||||
from quart import request as req
|
||||
parts = req.path.rstrip("/").split("/")
|
||||
try:
|
||||
idx = parts.index("product")
|
||||
g.product_slug = parts[idx + 1] if idx + 1 < len(parts) else None
|
||||
except (ValueError, IndexError):
|
||||
g.product_slug = None
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# BEFORE REQUEST: Slug or numeric ID resolver
|
||||
|
||||
Reference in New Issue
Block a user