UNPKG

@kiwicom/smart-faq

Version:

21 lines (15 loc) 584 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 = typeof window !== 'undefined' ? new URL(window.location.href).searchParams.get('ui') === 'webview' : false;