Skip to content

Commit

Permalink
remove trailing semicolon
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Feb 21, 2023
1 parent a324e23 commit 0f1a7f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CSPBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function compile(): string
$compiled []= 'upgrade-insecure-requests';
}

$this->compiled = implode('', $compiled);
$this->compiled = rtrim(implode('', $compiled), '; ');
$this->needsCompile = false;
return $this->compiled;
}
Expand Down
17 changes: 17 additions & 0 deletions test/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ public function testBasicFromData()
);
}

/**
* @throws \Exception
*/
public function testNoTrailingSemicolon()
{
$csp = (new CSPBuilder())
->setSelfAllowed('default-src', true)
->addSource('img-src', 'ytimg.com')
->disableOldBrowserSupport()
;

$this->assertEquals(
"default-src 'self'; img-src ytimg.com",
$csp->getCompiledHeader()
);
}

/**
* @throws \Exception
*/
Expand Down

0 comments on commit 0f1a7f7

Please sign in to comment.