Skip to content

Commit

Permalink
Fix expectsJson returning true when expecting html
Browse files Browse the repository at this point in the history
  • Loading branch information
jn-jairo committed Dec 18, 2017
1 parent 1c0a18c commit 5c9d906
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function isJson()
*/
public function expectsJson()
{
return ($this->ajax() && ! $this->pjax()) || $this->wantsJson();
return ($this->ajax() && ! $this->pjax() && ! $this->wantsHtml()) || $this->wantsJson();
}

/**
Expand All @@ -56,6 +56,18 @@ public function wantsJson()
return isset($acceptable[0]) && Str::contains($acceptable[0], ['/json', '+json']);
}

/**
* Determine if the current request is asking for HTML in return.
*
* @return bool
*/
public function wantsHtml()
{
$acceptable = $this->getAcceptableContentTypes();

return isset($acceptable[0]) && Str::contains($acceptable[0], ['/html', '/xhtml', '+html']);
}

/**
* Determines whether the current requests accepts a given content type.
*
Expand Down

0 comments on commit 5c9d906

Please sign in to comment.