diff --git a/ui/src/app/shared/utils.ts b/ui/src/app/shared/utils.ts index cf872f1587d5..123e0a47cef1 100644 --- a/ui/src/app/shared/utils.ts +++ b/ui/src/app/shared/utils.ts @@ -81,7 +81,14 @@ export const Utils = { }, get managedNamespace() { - return localStorage.getItem(managedNamespaceKey); + return this.fixLocalStorageString(localStorage.getItem(managedNamespaceKey)); + }, + + fixLocalStorageString(x: string): string { + // empty string is valid, so we cannot use `truthy` + if (x !== null && x !== 'null' && x !== 'undefined') { + return x; + } }, onNamespaceChange(value: string) { @@ -99,7 +106,7 @@ export const Utils = { get currentNamespace() { // we always prefer the managed namespace - return this.managedNamespace || localStorage.getItem(currentNamespaceKey); + return this.managedNamespace || this.fixLocalStorageString(localStorage.getItem(currentNamespaceKey)); }, // return a namespace, favoring managed namespace when set