Skip to content

Commit

Permalink
forced boolean type
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjeevLakhwani committed Sep 23, 2024
1 parent f0855a7 commit 4da1fd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { stringToBoolean } from '@/utils/strings';

interface PublicConfig {
CLIENT_NAME: string;
PORTAL_URL: string;
TRANSLATED: boolean;
BEACON_URL: string;
BEACON_UI_ENABLED: boolean;
BEACON_UI_ENABLED: string;
PUBLIC_URL: string;
CLIENT_ID: string;
OPENID_CONFIG_URL: string;
Expand All @@ -17,7 +19,9 @@ export const CLIENT_NAME = BENTO_PUBLIC_CONFIG.CLIENT_NAME ?? process.env.BENTO_
export const PORTAL_URL = BENTO_PUBLIC_CONFIG.PORTAL_URL ?? process.env.BENTO_PUBLIC_PORTAL_URL;
export const TRANSLATED = BENTO_PUBLIC_CONFIG.TRANSLATED ?? process.env.BENTO_PUBLIC_TRANSLATED;
export const BEACON_URL = BENTO_PUBLIC_CONFIG.BEACON_URL ?? process.env.BEACON_URL;
export const BEACON_UI_ENABLED = BENTO_PUBLIC_CONFIG.BEACON_UI_ENABLED ?? process.env.BENTO_BEACON_UI_ENABLED;
export const BEACON_UI_ENABLED = stringToBoolean(
BENTO_PUBLIC_CONFIG.BEACON_UI_ENABLED ?? process.env.BENTO_BEACON_UI_ENABLED
);

// Authentication
export const PUBLIC_URL = BENTO_PUBLIC_CONFIG.PUBLIC_URL ?? process.env.BENTO_PUBLIC_URL ?? '';
Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/strings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { DOI_PATTERN, URL_PATTERN } from '@/constants/patterns';

export const stringToBoolean = (s: string) => ['true', 't', '1', 'yes'].includes((s || '').toLocaleLowerCase());

export const stringIsDOI = (s: string) => !!s.match(DOI_PATTERN);
export const stringIsURL = (s: string) => !!s.match(URL_PATTERN);

0 comments on commit 4da1fd4

Please sign in to comment.