UNPKG

@kiwicom/smart-faq

Version:

27 lines (21 loc) 718 B
// @flow export const replaceDomain = (link: string, domain: string) => link.replace(/https?:\/\/[^/]+(?<path>.*)/, `${domain}$<path>`); export const replaceWithCurrentDomain = (url: string) => { if (typeof window === 'undefined') { return url; } return replaceDomain(url, window.location.origin); }; export const addDeepLink = (url: string, queryParam: string): string => `${url}?deeplink=${queryParam}&source=smartfaq`; export const isWebView = (() => { try { return typeof window !== 'undefined' ? new URL(window.location.href).searchParams.get('ui') === 'webview' : false; } catch (e) { // new URL fails in IE11 -> however IE11 is not webview return false; } })();