PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / lib / redirects.js

redirects.js in Extendify trunk, at src/Agent/lib/redirects.js

26 lines 640 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const { pluginRecommendations = [] } = window?.extAgentData?.agentContext || {};
2 const { adminUrl, homeUrl } = window?.extSharedData || {};
3
4 export const getRedirectUrl = (redirectTo, options = {}) => {
5 if (redirectTo?.type === 'plugin-setup') {
6 const plugin = pluginRecommendations.find(
7 ({ slug }) => slug === options.pluginSlug,
8 );
9 if (!plugin) return '';
10 return makeRedirectUrl(plugin.redirectTo);
11 }
12
13 return '';
14 };
15
16 const makeRedirectUrl = (url) => {
17 try {
18 return new URL(
19 url.replace('{{ADMIN_URL}}', adminUrl).replace('{{HOME_URL}}', homeUrl),
20 ).toString();
21 } catch (e) {
22 console.error(e);
23 return '';
24 }
25 };
26