Skip to content

Commit 73050f5

Browse files
authored
fix(utils): handle network error when fail to load svg (#1260)
1 parent 7428260 commit 73050f5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/utils/src/loader/svg-loader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const stripUnsafeNodes = (...elements: Node[]): void => {
5656
* @returns Is valid SVG
5757
*/
5858
const isValidResponse = (response: Response | undefined): response is Response => {
59-
const isSVG = Boolean(response?.headers.get('content-type')?.startsWith('image/svg+xml'));
59+
// Header might not be present in case of network error such as CORS issue
60+
const isSVG = Boolean(response?.headers?.get('content-type')?.startsWith('image/svg+xml'));
6061
return Boolean(response) && Boolean(response?.ok) && response?.status === 200 && isSVG;
6162
};
6263

0 commit comments

Comments
 (0)