Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #24 from TVke/fix-breaking-change
Browse files Browse the repository at this point in the history
Add test and default value to expose header
  • Loading branch information
freekmurze authored Apr 24, 2018
2 parents 98893ca + 3f67ae3 commit 3178076
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/Cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Spatie\Cors;

use Closure;
use Illuminate\Http\Response;
use Spatie\Cors\CorsProfile\CorsProfile;

class Cors
Expand Down
2 changes: 1 addition & 1 deletion src/CorsProfile/DefaultProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function allowHeaders(): array

public function exposeHeaders(): array
{
return config('cors.default_profile.expose_headers');
return config('cors.default_profile.expose_headers') ?? [];
}

public function maxAge(): int
Expand Down
13 changes: 13 additions & 0 deletions tests/CorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ public function it_sends_the_custom_forbidden_response_for_invalid_requests()
->assertSee($forbiddenMessage);
}

/** @test */
public function it_will_be_a_valid_profile_if_expose_header_is_not_set()
{
config()->set('cors.default_profile.expose_headers', null);

$this
->sendRequest('POST', 'https://spatie.be')
->assertSuccessful()
->assertHeader('Access-Control-Expose-Headers', '')
->assertHeader('Access-Control-Allow-Origin', '*')
->assertSee('real content');
}

public function sendRequest(string $method, string $origin)
{
$headers = [
Expand Down

0 comments on commit 3178076

Please sign in to comment.