Skip to content

Commit

Permalink
corrected logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjeevLakhwani committed Sep 25, 2024
1 parent 4da1fd4 commit 91e7ed4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions create_config_prod.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const parseBoolean = (value) => ['true', '1', 'yes'].includes((value || '').toLocaleLowerCase());
import { stringToBoolean } from '@/utils/strings';

const siteConfig = {
CLIENT_NAME: process.env.BENTO_PUBLIC_CLIENT_NAME || null,
PORTAL_URL: process.env.BENTO_PUBLIC_PORTAL_URL || null,
TRANSLATED: parseBoolean(process.env.BENTO_PUBLIC_TRANSLATED),
TRANSLATED: stringToBoolean(process.env.BENTO_PUBLIC_TRANSLATED),
BEACON_URL: process.env.BEACON_URL || null,
BEACON_UI_ENABLED: parseBoolean(process.env.BENTO_BEACON_UI_ENABLED),
BEACON_UI_ENABLED: stringToBoolean(process.env.BENTO_BEACON_UI_ENABLED),

// Authentication
PUBLIC_URL: process.env.BENTO_PUBLIC_URL || null,
Expand Down
7 changes: 3 additions & 4 deletions src/js/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface PublicConfig {
PORTAL_URL: string;
TRANSLATED: boolean;
BEACON_URL: string;
BEACON_UI_ENABLED: string;
BEACON_UI_ENABLED: boolean;
PUBLIC_URL: string;
CLIENT_ID: string;
OPENID_CONFIG_URL: string;
Expand All @@ -19,9 +19,8 @@ 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 = stringToBoolean(
BENTO_PUBLIC_CONFIG.BEACON_UI_ENABLED ?? process.env.BENTO_BEACON_UI_ENABLED
);
export const BEACON_UI_ENABLED =
BENTO_PUBLIC_CONFIG.BEACON_UI_ENABLED ?? stringToBoolean(process.env.BENTO_BEACON_UI_ENABLED);

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

export const stringToBoolean = (s: string) => ['true', 't', '1', 'yes'].includes((s || '').toLocaleLowerCase());
export const stringToBoolean = (s: string | undefined) =>
['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 91e7ed4

Please sign in to comment.