Skip to content

Commit cffc27d

Browse files
authored
Frontend URL Parser for configs
2 parents a195e0d + 2be1dae commit cffc27d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

frontend/src/app/shared/constants/config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { hasValue } from '@openmina/shared';
44

55
export const CONFIG: Readonly<MinaEnv> = {
66
...environment,
7+
configs: environment.configs.map((config) => ({
8+
...config,
9+
url: getURL(config.url),
10+
memoryProfiler: getURL(config.memoryProfiler),
11+
debugger: getURL(config.debugger),
12+
})),
713
};
814

915
(window as any).config = CONFIG;
@@ -36,3 +42,15 @@ export function isSubFeatureEnabled(config: MinaNode, feature: FeatureType, subF
3642
const features = getFeaturesConfig(config);
3743
return hasValue(features[feature]) && features[feature].includes(subFeature);
3844
}
45+
46+
47+
export function getURL(pathOrUrl: string): string {
48+
if (pathOrUrl) {
49+
let href = new URL(pathOrUrl, origin).href;
50+
if (href.endsWith('/')) {
51+
href = href.slice(0, -1);
52+
}
53+
return href;
54+
}
55+
return pathOrUrl;
56+
}

0 commit comments

Comments
 (0)