From 785d8e5cf05489f30765f690677804e3e9b023e5 Mon Sep 17 00:00:00 2001 From: Andy Buteau Date: Mon, 19 Aug 2019 13:42:07 -0700 Subject: [PATCH] Ensure window.location is defined React Native has a global 'window' object but it does not have a location field. This diff checks for window.location before trying to access window.location.protocol --- src/logger.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/logger.js b/src/logger.js index 25b7e1a..f9772f8 100644 --- a/src/logger.js +++ b/src/logger.js @@ -102,7 +102,8 @@ export function Logger({ url, prefix, logLevel = DEFAULT_LOG_LEVEL, transport = function immediateFlush() : ZalgoPromise { return ZalgoPromise.try(() => { - if (!isBrowser() || window.location.protocol === PROTOCOL.FILE) { + if (!isBrowser() || + ("undefined" != typeof window.location && window.location.protocol === PROTOCOL.FILE)) { return; }