1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00

Move extension refresh redirect util function to libs so other clients can use it (#10979)

This commit is contained in:
Jared Snider
2024-09-10 17:47:16 -04:00
committed by GitHub
parent 90330f798f
commit 546115876f
2 changed files with 2 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
import { inject } from "@angular/core";
import { UrlTree, Router } from "@angular/router";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
/**
* Helper function to redirect to a new URL based on the ExtensionRefresh feature flag.
* @param redirectUrl - The URL to redirect to if the ExtensionRefresh flag is enabled.
*/
export function extensionRefreshRedirect(redirectUrl: string): () => Promise<boolean | UrlTree> {
return async () => {
const configService = inject(ConfigService);
const router = inject(Router);
const shouldRedirect = await configService.getFeatureFlag(FeatureFlag.ExtensionRefresh);
if (shouldRedirect) {
return router.parseUrl(redirectUrl);
} else {
return true;
}
};
}