Skip to content

Commit 3f6f900

Browse files
author
aadamgough
committed
regex constant
1 parent 2a23bb8 commit 3f6f900

File tree

1 file changed

+4
-2
lines changed
  • apps/sim/app/api/auth/oauth/token

1 file changed

+4
-2
lines changed

apps/sim/app/api/auth/oauth/token/route.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const dynamic = 'force-dynamic'
1010

1111
const logger = createLogger('OAuthTokenAPI')
1212

13+
const SALESFORCE_INSTANCE_URL_REGEX = /__sf_instance__:([^\s]+)/
14+
1315
const tokenRequestSchema = z.object({
1416
credentialId: z
1517
.string({ required_error: 'Credential ID is required' })
@@ -81,7 +83,7 @@ export async function POST(request: NextRequest) {
8183

8284
let instanceUrl: string | undefined
8385
if (credential.providerId === 'salesforce' && credential.scope) {
84-
const instanceMatch = credential.scope.match(/__sf_instance__:([^\s]+)/)
86+
const instanceMatch = credential.scope.match(SALESFORCE_INSTANCE_URL_REGEX)
8587
if (instanceMatch) {
8688
instanceUrl = instanceMatch[1]
8789
}
@@ -161,7 +163,7 @@ export async function GET(request: NextRequest) {
161163
// For Salesforce, extract instanceUrl from the scope field
162164
let instanceUrl: string | undefined
163165
if (credential.providerId === 'salesforce' && credential.scope) {
164-
const instanceMatch = credential.scope.match(/__sf_instance__:([^\s]+)/)
166+
const instanceMatch = credential.scope.match(SALESFORCE_INSTANCE_URL_REGEX)
165167
if (instanceMatch) {
166168
instanceUrl = instanceMatch[1]
167169
}

0 commit comments

Comments
 (0)