RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/lib/utils/getConfig.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Meteor } from 'meteor/meteor';

export const getConfig = <T>(key: string, defaultValue?: T): string | null | T => {
    const searchParams = new URLSearchParams(window.location.search);

    const storedItem = searchParams.get(key) || Meteor._localStorage.getItem(`rc-config-${key}`);

    return storedItem ?? defaultValue ?? null;
};