Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Products/SiteAccess] handle wildcard on rewrite url #318

Merged
merged 5 commits into from Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGES.rst
Expand Up @@ -11,7 +11,10 @@ https://github.com/zopefoundation/Zope/blob/4.0a6/CHANGES.rst
4.0b8 (unreleased)
------------------

- Nothing changed yet.
New features
++++++++++++

- Add wildcard rewrite to sub host name in virtualHostMonster.


4.0b7 (2018-10-30)
Expand Down
2 changes: 2 additions & 0 deletions src/Products/SiteAccess/VirtualHostMonster.py
Expand Up @@ -173,6 +173,8 @@ def __call__(self, client, request, response=None):
stack[ii] = self.id
stack.insert(ii, '/')
ii += 1
if '*' in stack:
stack[stack.index('*')] = host.split('.')[0]
path = stack[:ii]
# If the directive is on top of the stack, go ahead
# and process it right away.
Expand Down
7 changes: 7 additions & 0 deletions src/Products/SiteAccess/tests/testVirtualHostMonster.py
Expand Up @@ -98,6 +98,13 @@ def test_actual_url_w_VHR_no_doc_no_trailing_slash(self):
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://www.mysite.com/')

def testWildcardRewrite(self):
ob = self.traverse('/VirtualHostBase/http/doc.example.com:80'
'/folder/*/VirtualHostRoot')
self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://doc.example.com/')
self.assertEqual(ob.getPhysicalPath(), ('', 'folder', 'doc'))


def gen_cases():
for vbase, ubase in (
Expand Down