Skip to content

Commit

Permalink
fixes issue where a json null could throw an exception (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Jan 27, 2019
1 parent 7ed5359 commit 71d9016
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions masonite/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ def _get_standardized_value(self, value):
Returns:
string|bool
"""
if value is None:
return None

if isinstance(value, list):

# If the list contains MiniFieldStorage objects then loop through and get the values.
Expand Down
16 changes: 16 additions & 0 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,22 @@ def test_redirect_compiles_url_with_http(self):
route = "http://google.com"

assert request.compile_route_to_url(route) == 'http://google.com'

def test_can_get_nully_value(self):
app = App()
app.bind('Request', self.request)
request = app.make('Request').load_app(app)

request._set_standardized_request_variables({
"gateway": "RENDIMENTO",
"request": {
"user": "data"
},
"response": None,
"description": "test only"
})

assert request.input('response') == None

def test_request_gets_correct_header(self):
app = App()
Expand Down

0 comments on commit 71d9016

Please sign in to comment.