| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5294372 commit 2e92db2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -604,14 +604,14 @@ public function accepts($contentTypes) | |||
| 604 | 604 | ||
| 605 | 605 | foreach ((array) $contentTypes as $type) | |
| 606 | 606 | { | |
| 607 | - $split = explode('/', $type); | ||
| 608 | - | ||
| 609 | - if ($accept === $type || $accept === $split[0].'/*') | ||
| 607 | + if ($accept === $type || $accept === strtok('/', $type).'/*') | ||
| 610 | 608 | { | |
| 611 | 609 | return true; | |
| 612 | 610 | } | |
| 613 | 611 | ||
| 614 | - if (preg_match('/'.$split[0].'\/.+\+'.$split[1].'/', $accept)) | ||
| 612 | + $split = explode('/', $accept); | ||
| 613 | + | ||
| 614 | + if (preg_match('/'.$split[0].'\/.+\+'.$split[1].'/', $type)) | ||
| 615 | 615 | { | |
| 616 | 616 | return true; | |
| 617 | 617 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -450,12 +450,14 @@ public function testFormatReturnsAcceptsJson() | |||
| 450 | 450 | $request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => 'application/json']); | |
| 451 | 451 | $this->assertEquals('json', $request->format()); | |
| 452 | 452 | $this->assertTrue($request->accepts('application/json')); | |
| 453 | + $this->assertTrue($request->accepts('application/baz+json')); | ||
| 453 | 454 | $this->assertTrue($request->acceptsJson()); | |
| 454 | 455 | $this->assertFalse($request->acceptsHtml()); | |
| 455 | 456 | ||
| 456 | 457 | $request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => 'application/foo+json']); | |
| 457 | 458 | $this->assertTrue($request->accepts('application/foo+json')); | |
| 458 | - $this->assertTrue($request->accepts('application/json')); | ||
| 459 | + $this->assertFalse($request->accepts('application/bar+json')); | ||
| 460 | + $this->assertFalse($request->accepts('application/json')); | ||
| 459 | 461 | ||
| 460 | 462 | $request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => 'application/*']); | |
| 461 | 463 | $this->assertTrue($request->accepts('application/xml')); | |
@@ -477,13 +479,26 @@ public function testFormatReturnsAcceptsHtml() | |||
| 477 | 479 | } | |
| 478 | 480 | ||
| 479 | 481 | ||
| 482 | + public function testFormatReturnsAcceptsAll() | ||
| 483 | + { | ||
| 484 | + $request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => '*/*']); | ||
| 485 | + $this->assertEquals('html', $request->format()); | ||
| 486 | + $this->assertTrue($request->accepts('text/html')); | ||
| 487 | + $this->assertTrue($request->accepts('foo/bar')); | ||
| 488 | + $this->assertTrue($request->accepts('application/baz+xml')); | ||
| 489 | + $this->assertTrue($request->acceptsHtml()); | ||
| 490 | + $this->assertTrue($request->acceptsJson()); | ||
| 491 | + } | ||
| 492 | + | ||
| 493 | + | ||
| 480 | 494 | public function testFormatReturnsAcceptsMultiple() | |
| 481 | 495 | { | |
| 482 | 496 | $request = Request::create('/', 'GET', [], [], [], ['HTTP_ACCEPT' => 'application/json,text/*']); | |
| 483 | 497 | $this->assertTrue($request->accepts(['text/html', 'application/json'])); | |
| 484 | 498 | $this->assertTrue($request->accepts('text/html')); | |
| 485 | 499 | $this->assertTrue($request->accepts('text/foo')); | |
| 486 | 500 | $this->assertTrue($request->accepts('application/json')); | |
| 501 | + $this->assertTrue($request->accepts('application/baz+json')); | ||
| 487 | 502 | } | |
| 488 | 503 | ||
| 489 | 504 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments