From afd1a3e14d726e69bd07c613814d79cb108cabe7 Mon Sep 17 00:00:00 2001 From: Danny Date: Sat, 26 Nov 2022 13:11:36 +0000 Subject: [PATCH] fix: patches for react native 6 --- lib/api/src/modules/refs.ts | 2 +- lib/preview-web/src/PreviewWeb.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/src/modules/refs.ts b/lib/api/src/modules/refs.ts index e86f28a923b8..56aa2d4cd52a 100644 --- a/lib/api/src/modules/refs.ts +++ b/lib/api/src/modules/refs.ts @@ -75,7 +75,7 @@ const findFilename = /(\/((?:[^\/]+?)\.[^\/]+?)|\/)$/; export const getSourceType = (source: string, refId: string) => { const { origin: localOrigin, pathname: localPathname } = location; - const { origin: sourceOrigin, pathname: sourcePathname } = new URL(source); + const { origin: sourceOrigin, pathname: sourcePathname } = new URL(source || location.origin); const localFull = `${localOrigin + localPathname}`.replace(findFilename, ''); const sourceFull = `${sourceOrigin + sourcePathname}`.replace(findFilename, ''); diff --git a/lib/preview-web/src/PreviewWeb.tsx b/lib/preview-web/src/PreviewWeb.tsx index 891eb1dd5337..6e73f1e050ec 100644 --- a/lib/preview-web/src/PreviewWeb.tsx +++ b/lib/preview-web/src/PreviewWeb.tsx @@ -58,11 +58,11 @@ export class PreviewWeb extends Preview; - constructor() { + constructor(urlStore: UrlStore = new UrlStore(), webview: WebView = new WebView()) { super(); - this.view = new WebView(); - this.urlStore = new UrlStore(); + this.view = webview; + this.urlStore = urlStore; // Add deprecated APIs for back-compat // @ts-ignore