Skip to content

Commit

Permalink
Merge pull request dingo#673 from lucasmichot/feature/master.accept-p…
Browse files Browse the repository at this point in the history
…arse-default

No need to set $default if BadRequestHttpException is thrown
  • Loading branch information
jasonlewis committed Oct 13, 2015
2 parents b8e0752 + 3ca1005 commit 73292b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Http/Parser/Accept.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public function __construct($standardsTree, $subtype, $version, $format)
*/
public function parse(Request $request, $strict = false)
{
$default = 'application/'.$this->standardsTree.'.'.$this->subtype.'.'.$this->version.'+'.$this->format;

$pattern = '/application\/'.$this->standardsTree.'\.('.$this->subtype.')\.(v?[\d\.]+)\+([\w]+)/';

if (! preg_match($pattern, $request->header('accept'), $matches)) {
if ($strict) {
throw new BadRequestHttpException('Accept header could not be properly parsed because of a strict matching process.');
}

$default = 'application/'.$this->standardsTree.'.'.$this->subtype.'.'.$this->version.'+'.$this->format;

preg_match($pattern, $default, $matches);
}

Expand Down

0 comments on commit 73292b6

Please sign in to comment.