FIX for: PY4WEB_URL_PREFIX fails if the name of an app is the same like /p/pse
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
The issue is in py4web/core.py where URL_PREFIX handling strips the prefix incorrectly when app names start with the same pattern. Start by examining the register_route logic and how URL() builds links. The fix is provided in the issue body; apply it and test by creating an app with a name starting with the prefix (like 'pse') and verify that links, redirects, static paths, and form actions include the correct /p prefix.
Written by the indexing model from the issue text.
Description
What ever is used a URL_PREFIX will break if the app name starts with the same pattern.
Using PY4WEB_URL_PREFIX=/p
So any app whose name starts with p gets links, redirects, static paths and form actions without the /p prefix. The routes themselves are registered correctly by register_route, so if you type /p/pse directly the page should load. Anything built with URL() after that breaks.
The fix
py4web/core.py:
url_prefix = os.environ.get("PY4WEB_URL_PREFIX", "")
if url_prefix and prefix and (
prefix == url_prefix or prefix.startswith(url_prefix.rstrip("/") + "/")):
url_prefix = ""
- Dominant language
- HTML
- Stars
- 319
- Forks
- 144
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from web2py/py4web
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
microsoft/magentic-ui#588 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
alexgorbatchev/simple-ptt#3 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
CorrelAid/formtransform#44 ·