8000 docs: Writing an extensive docstring for view _clean_redirect_url in … · django-cms/django-cms@caef9f3 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit caef9f3

Browse files
docs: Writing an extensive docstring for view _clean_redirect_url in the ma… (#7620)
* Writing an extensive docstring for view _clean_redirect_url in the main views file * Fixed _clean_redirect_url view docstring after review --------- Co-authored-by: Fabian Braun <fsbraun@gmx.de>
1 parent cb697e3 commit caef9f3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cms/views.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@
3434

3535

3636
def _clean_redirect_url(redirect_url, language):
37+
"""
38+
Cleans the redirect URL based on the given language.
39+
40+
This function checks if the URL is using language prefix patterns and if the provided
41+
redirect URL needs to be modified to include the language prefix. If the URL is not
42+
already starting with the language prefix, it adds the language prefix at the beginning
43+
of the URL.
44+
45+
Note:
46+
This is a private function, it is not recommended to use it in third party code.
47+
48+
Parameters:
49+
redirect_url (str): The original redirect URL that may need to be modified.
50+
language (str): The language code to be used as the prefix in the URL.
51+
52+
Returns:
53+
str: The cleaned redirect URL with the appropriate language prefix.
54+
55+
Example:
56+
For example, if the language is 'en' and the redirect_url is '/about/', this function
57+
will return '/en/about/' if language prefix patterns are used.
58+
59+
If the language is 'es' and the redirect_url is '/contact/', and language prefix
60+
patterns are not used, the function will return '/es/contact/' as well.
61+
"""
3762
if (redirect_url and is_language_prefix_patterns_used() and redirect_url[0] == "/" and not redirect_url.startswith(
3863
'/%s/' % language)):
3964
# add language prefix to url

0 commit comments

Comments
 (0)
0