Skip to content

Commit

Permalink
Merge pull request #41 from City-of-Helsinki/UHF-5618_add_missing_xml…
Browse files Browse the repository at this point in the history
…_content_type

UHF-5618: rss feed would not be handled as xml
  • Loading branch information
rpnykanen authored Sep 20, 2022
2 parents 6560bff + 0d1b532 commit 3ca44d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/HttpMiddleware/AssetHttpMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ private function isXmlResponse(Response $response) : bool {
if (!$response->headers->has('content-type')) {
return FALSE;
}
return str_starts_with(
$response->headers->get('content-type') ?: '',
'application/xml',
);
foreach (['application/xml', 'application/rss+xml'] as $type) {
if (str_starts_with($response->headers->get('content-type'), $type)) {
return TRUE;
}
}
return FALSE;
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/src/Unit/AssetHttpMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function xmlResponseProvider() : array {
return [
['application/xml'],
['application/xml; charset=utf-8'],
['application/rss+xml; charset=utf-8'],
];
}

Expand Down

0 comments on commit 3ca44d3

Please sign in to comment.