()
| 47 | * can pass this to `setRouter` to make it the global router. |
| 48 | */ |
| 49 | export function createRouter(): Router { |
| 50 | return { |
| 51 | environment: () => createDataPath('/environment'), |
| 52 | experiments: () => createDataPath('/experiments'), |
| 53 | pluginRoute: ( |
| 54 | pluginName: string, |
| 55 | route: string, |
| 56 | params?: URLSearchParams |
| 57 | ): string => { |
| 58 | return createDataPath(`/plugin/${pluginName}${route}`, params); |
| 59 | }, |
| 60 | pluginRouteForSrc: ( |
| 61 | pluginName: string, |
| 62 | route: string, |
| 63 | params: URLSearchParams = new URLSearchParams() |
| 64 | ): string => { |
| 65 | const featureFlags = getFeatureFlagsToSendToServer(); |
| 66 | if (Object.keys(featureFlags).length > 0) { |
| 67 | params.append( |
| 68 | FEATURE_FLAGS_QUERY_STRING_NAME, |
| 69 | JSON.stringify(featureFlags) |
| 70 | ); |
| 71 | } |
| 72 | return createDataPath(`/plugin/${pluginName}${route}`, params); |
| 73 | }, |
| 74 | pluginsListing: () => |
| 75 | createDataPath( |
| 76 | '/plugins_listing', |
| 77 | createSearchParam({ |
| 78 | [EXPERIMENTAL_PLUGINS_QUERY_PARAM]: initialURLSearchParams.getAll( |
| 79 | EXPERIMENTAL_PLUGINS_QUERY_PARAM |
| 80 | ), |
| 81 | }) |
| 82 | ), |
| 83 | runs: () => createDataPath('/runs'), |
| 84 | }; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * @return {Router} the global router |
no test coverage detected
searching dependent graphs…