Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 657e942

Browse files
committed
Fixed isFile check not working when no source is provided
1 parent 12802f2 commit 657e942

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const imageCacheHoc = <P extends object>(
236236
// Set url from source prop
237237
const url = traverse(this.props).get(['source', 'uri'])
238238
const cacheStrategy = traverse(this.props).get(['source', 'cache']) || 'immutable'
239-
const isFile = new URL(url).protocol === 'file:'
239+
const isFile = url && new URL(url).protocol === 'file:'
240240

241241
if (isFile || !this.invalidUrl) {
242242
if (isFile) {
@@ -269,7 +269,7 @@ const imageCacheHoc = <P extends object>(
269269
// Set urls from source prop data
270270
const url = traverse(prevProps).get(['source', 'uri'])
271271
const nextUrl = traverse(this.props).get(['source', 'uri'])
272-
const isFile = new URL(nextUrl).protocol === 'file:'
272+
const isFile = nextUrl && new URL(nextUrl).protocol === 'file:'
273273

274274
// Do nothing if url has not changed.
275275
if (url === nextUrl) return

0 commit comments

Comments
 (0)