diff --git a/phpunit.xml.dist b/phpunit.xml.dist index feb46b0..3d7f866 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ info('The public URL of the manifest file.') ->example('/site.manifest') ->end() + ->booleanNode('use_credentials') + ->defaultTrue() + ->info('Indicates whether the manifest should be fetched with credentials.') + ->end() ->scalarNode('background_color') ->info( 'The background color of the application. It should match the background-color CSS property in the sites stylesheet for a smooth transition between launching the web application and loading the site\'s content.' diff --git a/src/Twig/PwaRuntime.php b/src/Twig/PwaRuntime.php index e55388c..e3ca916 100644 --- a/src/Twig/PwaRuntime.php +++ b/src/Twig/PwaRuntime.php @@ -56,8 +56,12 @@ public function load( private function injectManifestFile(string $output): string { $url = $this->assetMapper->getPublicPath($this->manifestPublicUrl) ?? $this->manifestPublicUrl; + $useCredentials = ''; + if ($this->manifest->useCredentials === true) { + $useCredentials = ' crossorigin="use-credentials"'; + } - return $output . sprintf('%s', PHP_EOL, $url); + return $output . sprintf('%s', PHP_EOL, $useCredentials, $url); } private function injectThemeColor(string $output, bool $themeColor): string diff --git a/tests/autoload.php b/tests/autoload.php new file mode 100644 index 0000000..552064b --- /dev/null +++ b/tests/autoload.php @@ -0,0 +1,9 @@ +