Revision 55baa300
b/snf-astakos-app/astakos/im/util.py | ||
---|---|---|
106 | 106 |
>>> print restrict_next('/im/feedback', '.okeanos.grnet.gr') |
107 | 107 |
/im/feedback |
108 | 108 |
>>> print restrict_next('pithos.okeanos.grnet.gr/im/feedback', '.okeanos.grnet.gr') |
109 |
pithos.okeanos.grnet.gr/im/feedback |
|
109 |
//pithos.okeanos.grnet.gr/im/feedback
|
|
110 | 110 |
>>> print restrict_next('https://pithos.okeanos.grnet.gr/im/feedback', '.okeanos.grnet.gr') |
111 | 111 |
https://pithos.okeanos.grnet.gr/im/feedback |
112 | 112 |
>>> print restrict_next('pithos://127.0.0,1', '.okeanos.grnet.gr') |
... | ... | |
124 | 124 |
>>> print restrict_next('//node1.example.com') |
125 | 125 |
//node1.example.com |
126 | 126 |
>>> print restrict_next('node1.example.com') |
127 |
node1.example.com |
|
127 |
//node1.example.com
|
|
128 | 128 |
""" |
129 | 129 |
if not url: |
130 | 130 |
return |
131 | 131 |
parts = urlparse(url, scheme='http') |
132 |
if not parts.netloc: |
|
132 |
if not parts.netloc and not parts.path.startswith('/'):
|
|
133 | 133 |
# fix url if does not conforms RFC 1808 |
134 | 134 |
url = '//%s' % url |
135 | 135 |
parts = urlparse(url, scheme='http') |
... | ... | |
180 | 180 |
|
181 | 181 |
if not next: |
182 | 182 |
next = reverse('astakos.im.views.index') |
183 |
|
|
183 |
|
|
184 | 184 |
response['Location'] = next |
185 | 185 |
response.status_code = 302 |
186 | 186 |
return response |
Also available in: Unified diff