1+ import { safeTrim , toLowerSafe } from './stringUtils.js' ;
12const BUILD_DEBUG_MODE = 'prod' ;
23const BUILD_DEBUG_ENABLED = false ;
34const DEBUG_STATE_STORAGE_KEY = 'toolbox.sample.asteroids.debug.enabled' ;
45
5- function sanitizeText ( value ) {
6- return typeof value === 'string' ? value . trim ( ) : '' ;
7- }
8-
96export function parseBooleanFlag ( value , fallback ) {
10- const normalized = sanitizeText ( value ) . toLowerCase ( ) ;
7+ const normalized = toLowerSafe ( value ) ;
118 if ( ! normalized ) {
129 return fallback ;
1310 }
@@ -21,7 +18,7 @@ export function parseBooleanFlag(value, fallback) {
2118}
2219
2320export function normalizeDebugMode ( value , fallback = 'prod' ) {
24- const normalized = sanitizeText ( value ) . toLowerCase ( ) ;
21+ const normalized = toLowerSafe ( value ) ;
2522 if ( normalized === 'dev' || normalized === 'qa' || normalized === 'prod' ) {
2623 return normalized ;
2724 }
@@ -61,8 +58,8 @@ export function writeStoredBoolean(key, value) {
6158}
6259
6360export function isLocalDebugEnvironment ( documentRef ) {
64- const protocol = sanitizeText ( documentRef ?. location ?. protocol ) || sanitizeText ( globalThis ?. location ?. protocol ) ;
65- const hostname = sanitizeText ( documentRef ?. location ?. hostname ) || sanitizeText ( globalThis ?. location ?. hostname ) ;
61+ const protocol = safeTrim ( documentRef ?. location ?. protocol ) || safeTrim ( globalThis ?. location ?. protocol ) ;
62+ const hostname = safeTrim ( documentRef ?. location ?. hostname ) || safeTrim ( globalThis ?. location ?. hostname ) ;
6663
6764 if ( protocol === 'file:' ) {
6865 return true ;
@@ -72,7 +69,7 @@ export function isLocalDebugEnvironment(documentRef) {
7269}
7370
7471export function resolveDebugConfig ( documentRef ) {
75- const search = sanitizeText ( documentRef ?. location ?. search ) || sanitizeText ( globalThis ?. location ?. search ) ;
72+ const search = safeTrim ( documentRef ?. location ?. search ) || safeTrim ( globalThis ?. location ?. search ) ;
7673 const searchParams = new URLSearchParams ( search ) ;
7774 const queryMode = searchParams . get ( 'debugMode' ) ;
7875 const queryEnabled = searchParams . get ( 'debug' ) ;
0 commit comments