@@ -541,24 +541,32 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
541541 * @returns An object with validation results: { isValid, arnRegion, errorMessage }
542542 */
543543 private parseArn ( arn : string , region ?: string ) {
544- // Use a single regex to capture the region and optional resource type/ID
545- // This matches ARNs like:
546- // Foundation Model: arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-v2
547- // Prompt Router: arn:aws:bedrock:us-west-2:123456789012:prompt-router/anthropic-claude
548- // Inference Profile: arn:aws:bedrock:us-west-2:123456789012:inference-profile/anthropic.claude-v2
549- // Cross Region Inference Profile: arn:aws:bedrock:us-west-2:123456789012:inference-profile/us.anthropic.claude-3-5-sonnet-20241022-v2:0
550- // Custom Model (Provisioned Throughput): arn:aws:bedrock:us-west-2:123456789012:provisioned-model/my-custom-model
551- // Imported Model: arn:aws:bedrock:us-west-2:123456789012:imported-model/my-imported-model
544+ /*
545+ * VIA Roo analysis: platform-independent Regex. It's designed to parse AWS Bedrock ARNs and doesn't rely on any platform-specific features
546+ * like file path separators, line endings, or case sensitivity behaviors. The forward slashes in the regex are properly escaped and
547+ * represent literal characters in the AWS ARN format, not filesystem paths. This regex will function consistently across Windows,
548+ * macOS, Linux, and any other operating system where JavaScript runs.
549+ *
550+ * This matches ARNs like:
551+ * - Foundation Model: arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-v2
552+ * - Prompt Router: arn:aws:bedrock:us-west-2:123456789012:prompt-router/anthropic-claude
553+ * - Inference Profile: arn:aws:bedrock:us-west-2:123456789012:inference-profile/anthropic.claude-v2
554+ * - Cross Region Inference Profile: arn:aws:bedrock:us-west-2:123456789012:inference-profile/us.anthropic.claude-3-5-sonnet-20241022-v2:0
555+ * - Custom Model (Provisioned Throughput): arn:aws:bedrock:us-west-2:123456789012:provisioned-model/my-custom-model
556+ * - Imported Model: arn:aws:bedrock:us-west-2:123456789012:imported-model/my-imported-model
557+ *
558+ * match[0] - The entire matched string
559+ * match[1] - The region (e.g., "us-east-1")
560+ * match[2] - The account ID (can be empty string for AWS-managed resources)
561+ * match[3] - The resource type (e.g., "foundation-model")
562+ * match[4] - The resource ID (e.g., "anthropic.claude-3-sonnet-20240229-v1:0")
563+ */
552564
553565 const arnRegex = / ^ a r n : a w s : b e d r o c k : ( [ ^ : ] + ) : ( [ ^ : ] * ) : (?: ( [ ^ \/ ] + ) \/ ( .+ ) | ( [ ^ \/ ] + ) ) $ /
554566 let match = arn . match ( arnRegex )
555567
556568 /*
557- match[0] - The entire matched string
558- match[1] - The region (e.g., "us-east-1")
559- match[2] - The account ID (can be empty string for AWS-managed resources)
560- match[3] - The resource type (e.g., "foundation-model")
561- match[4] - The resource ID (e.g., "anthropic.claude-3-sonnet-20240229-v1:0")
569+
562570 */
563571
564572 if ( match && match [ 1 ] && match [ 3 ] && match [ 4 ] ) {
0 commit comments