Skip to content

Commit c82bf64

Browse files
Hoist baseURL internal-whitespace regex constant
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent c8bdcd9 commit c82bf64

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/ai/src/chatTransport.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ const BASE_URL_VALIDATION_ERRORS = {
457457
credentials: "baseURL must not include username or password credentials",
458458
} as const;
459459

460+
const INTERNAL_WHITESPACE_REGEX = /\s/;
461+
460462
function resolvePayloadMapper<
461463
UI_MESSAGE extends UIMessage,
462464
PAYLOAD,
@@ -492,7 +494,7 @@ function normalizeBaseUrl(baseURL: string) {
492494
}
493495

494496
function assertBaseUrlHasNoInternalWhitespace(baseUrl: string) {
495-
if (/\s/.test(baseUrl)) {
497+
if (INTERNAL_WHITESPACE_REGEX.test(baseUrl)) {
496498
throw new Error(BASE_URL_VALIDATION_ERRORS.containsWhitespace);
497499
}
498500
}

0 commit comments

Comments
 (0)