From 4f75c727cac7249388b9113e6e7f82cd987c1c84 Mon Sep 17 00:00:00 2001 From: duxizhi <3161377+polaris-dxz@users.noreply.github.com> Date: Thu, 29 Sep 2022 21:00:44 +0800 Subject: [PATCH] fix NextJS breaks Mixpanel snippet(#301) https://github.com/vercel/next.js/issues/4480 https://github.com/mixpanel/mixpanel-js/issues/301 --- mixpanel-jslib-snippet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixpanel-jslib-snippet.js b/mixpanel-jslib-snippet.js index 9c9a1c65..e36fbc58 100644 --- a/mixpanel-jslib-snippet.js +++ b/mixpanel-jslib-snippet.js @@ -92,7 +92,7 @@ var MIXPANEL_LIB_URL = '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'; if (typeof MIXPANEL_CUSTOM_LIB_URL !== 'undefined') { script.src = MIXPANEL_CUSTOM_LIB_URL; - } else if (document.location.protocol === 'file:' && MIXPANEL_LIB_URL.match(/^\/\//)) { + } else if (document.location.protocol === 'file:' && MIXPANEL_LIB_URL.match(/^\\/\\//)) { script.src = 'https:' + MIXPANEL_LIB_URL; } else { script.src = MIXPANEL_LIB_URL;