|
3 | 3 | */
|
4 | 4 | import { products, influxdb_urls } from '@params';
|
5 | 5 |
|
| 6 | +const safeProducts = products || {}; |
| 7 | +const safeUrls = influxdb_urls || {}; |
| 8 | + |
6 | 9 | function getCurrentProductData() {
|
7 | 10 | const path = window.location.pathname;
|
8 | 11 | const mappings = [
|
9 |
| - { pattern: /\/influxdb\/cloud\//, product: products.cloud, urls: influxdb_urls.influxdb_cloud }, |
10 |
| - { pattern: /\/influxdb3\/core/, product: products.influxdb3_core, urls: influxdb_urls.core }, |
11 |
| - { pattern: /\/influxdb3\/enterprise/, product: products.influxdb3_enterprise, urls: influxdb_urls.enterprise }, |
12 |
| - { pattern: /\/influxdb3\/cloud-serverless/, product: products.influxdb3_cloud_serverless, urls: influxdb_urls.cloud }, |
13 |
| - { pattern: /\/influxdb3\/cloud-dedicated/, product: products.influxdb3_cloud_dedicated, urls: influxdb_urls.dedicated }, |
14 |
| - { pattern: /\/influxdb3\/clustered/, product: products.influxdb3_clustered, urls: influxdb_urls.clustered }, |
15 |
| - { pattern: /\/enterprise_v1\//, product: products.enterprise_influxdb, urls: influxdb_urls.oss }, |
16 |
| - { pattern: /\/influxdb.*v1\//, product: products.influxdb, urls: influxdb_urls.oss }, |
17 |
| - { pattern: /\/influxdb.*v2\//, product: products.influxdb, urls: influxdb_urls.oss }, |
18 |
| - { pattern: /\/kapacitor\//, product: products.kapacitor, urls: influxdb_urls.oss }, |
19 |
| - { pattern: /\/telegraf\//, product: products.telegraf, urls: influxdb_urls.oss }, |
20 |
| - { pattern: /\/chronograf\//, product: products.chronograf, urls: influxdb_urls.oss }, |
21 |
| - { pattern: /\/flux\//, product: products.flux, urls: influxdb_urls.oss }, |
| 12 | + { pattern: /\/influxdb\/cloud\//, product: safeProducts.cloud, urls: safeUrls.influxdb_cloud }, |
| 13 | + { pattern: /\/influxdb3\/core/, product: safeProducts.influxdb3_core, urls: safeUrls.core }, |
| 14 | + { pattern: /\/influxdb3\/enterprise/, product: safeProducts.influxdb3_enterprise, urls: safeUrls.enterprise }, |
| 15 | + { pattern: /\/influxdb3\/cloud-serverless/, product: safeProducts.influxdb3_cloud_serverless, urls: safeUrls.cloud }, |
| 16 | + { pattern: /\/influxdb3\/cloud-dedicated/, product: safeProducts.influxdb3_cloud_dedicated, urls: safeUrls.dedicated }, |
| 17 | + { pattern: /\/influxdb3\/clustered/, product: safeProducts.influxdb3_clustered, urls: safeUrls.clustered }, |
| 18 | + { pattern: /\/enterprise_v1\//, product: safeProducts.enterprise_influxdb, urls: safeUrls.oss }, |
| 19 | + { pattern: /\/influxdb.*v1\//, product: safeProducts.influxdb, urls: safeUrls.oss }, |
| 20 | + { pattern: /\/influxdb.*v2\//, product: safeProducts.influxdb, urls: safeUrls.oss }, |
| 21 | + { pattern: /\/kapacitor\//, product: safeProducts.kapacitor, urls: safeUrls.oss }, |
| 22 | + { pattern: /\/telegraf\//, product: safeProducts.telegraf, urls: safeUrls.oss }, |
| 23 | + { pattern: /\/chronograf\//, product: safeProducts.chronograf, urls: safeUrls.oss }, |
| 24 | + { pattern: /\/flux\//, product: safeProducts.flux, urls: safeUrls.oss }, |
22 | 25 | ];
|
23 | 26 |
|
24 | 27 | for (const { pattern, product, urls } of mappings) {
|
25 | 28 | if (pattern.test(path)) {
|
26 |
| - return { product, urls }; |
| 29 | + return { |
| 30 | + product: product || 'unknown', |
| 31 | + urls: urls || {} |
| 32 | + }; |
27 | 33 | }
|
28 | 34 | }
|
29 | 35 |
|
30 |
| - return 'other'; |
| 36 | + return { product: 'other', urls: {} }; |
31 | 37 | }
|
32 | 38 |
|
33 | 39 | // Return the page context (cloud, serverless, oss/enterprise, dedicated, clustered, other)
|
|
0 commit comments