You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/** 阶段0录证专用环境解析( 独立于 workers/rpa) */
const FORBIDDEN_QUOTE_URL_PATTERNS : RegExp [ ] = [
/dashboard\.mothership\.com/i ,
/www\.mothership\.com\/quote/i ,
] ;
export function parseQuoteUrls ( raw : string | undefined ) : string [ ] {
if ( ! raw ? . trim ( ) ) {
return [ ] ;
}
return raw
. split ( "," )
. map ( ( item ) = > item . trim ( ) )
. filter ( Boolean ) ;
}
export function isForbiddenQuoteUrl ( url : string ) : boolean {
return FORBIDDEN_QUOTE_URL_PATTERNS . some ( ( pattern ) = > pattern . test ( url ) ) ;
}
export function resolveEntryUrl ( ) : string {
const urls = parseQuoteUrls ( process . env . MOTHERSHIP_QUOTE_URLS ) ;
const first = urls [ 0 ] ;
if ( ! first ) {
throw new Error (
"MOTHERSHIP_QUOTE_URLS 未配置。请在 .env 中设置 headed 录制验证的匿名入口 URL。" ,
) ;
}
if ( isForbiddenQuoteUrl ( first ) ) {
throw new Error ( ` 禁止的报价入口 URL( GD-15) : ${ first } ` ) ;
}
try {
new URL ( first ) ;
} catch {
throw new Error ( ` 无效的报价入口 URL: ${ first } ` ) ;
}
return first ;
}
export function resolveBrowserChannel ( ) : string | undefined {
const channel = process . env . RPA_BROWSER_CHANNEL ? . trim ( ) ;
return channel || undefined ;
}