Skip to content

Commit

Permalink
Merge ac7a53b into fd7506c
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Aug 9, 2018
2 parents fd7506c + ac7a53b commit dc28d21
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion masonite/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def compile_route_to_regex(self, route):
regex += r'([a-zA-Z]+)'
else:
# default
regex += r'(\w+)'
regex += r'([\w.-]+)'
regex += r'\/'

# append the variable name passed @(variable):int to a list
Expand Down
28 changes: 28 additions & 0 deletions tests/providers/test_route_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ def test_sets_request_params(self):

assert self.app.make('Request').param('id') == '1'

def test_url_with_dots_finds_route(self):
self.app.make('Route').url = '/test/user.endpoint'
self.app.bind('WebRoutes', [get('/test/@endpoint', ControllerTest.show)])

self.provider.boot(
self.app.make('WebRoutes'),
self.app.make('Route'),
self.app.make('Request'),
self.app.make('Environ'),
self.app.make('Headers'),
)

assert self.app.make('Request').param('endpoint') == 'user.endpoint'

def test_url_with_dashes_finds_route(self):
self.app.make('Route').url = '/test/user-endpoint'
self.app.bind('WebRoutes', [get('/test/@endpoint', ControllerTest.show)])

self.provider.boot(
self.app.make('WebRoutes'),
self.app.make('Route'),
self.app.make('Request'),
self.app.make('Environ'),
self.app.make('Headers'),
)

assert self.app.make('Request').param('endpoint') == 'user-endpoint'

def test_route_subdomain_ignores_routes(self):
self.app.make('Route').url = '/test'
self.app.make('Environ')['HTTP_HOST'] = 'subb.domain.com'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_route_is_post(self):
def test_compile_route_to_regex(self):
assert self.route.compile_route_to_regex(Get().route('test/route', None)) == '^test\\/route\\/$'
assert self.route.compile_route_to_regex(Get().route(
'test/@route', None)) == '^test\\/(\\w+)\\/$'
'test/@route', None)) == '^test\\/([\\w.-]+)\\/$'

assert self.route.compile_route_to_regex(Get().route(
'test/@route:int', None)) == '^test\\/(\\d+)\\/$'
Expand Down

0 comments on commit dc28d21

Please sign in to comment.