mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Do not use url.includes to check for domain names (#13802)
This commit is contained in:
committed by
GitHub
parent
9d698edceb
commit
d3bc80c22b
@@ -104,8 +104,8 @@ export class LmChatOpenAi implements INodeType {
|
||||
properties: {
|
||||
// If the baseURL is not set or is set to api.openai.com, include only chat models
|
||||
pass: `={{
|
||||
($parameter.options?.baseURL && !$parameter.options?.baseURL?.includes('api.openai.com')) ||
|
||||
($credentials?.url && !$credentials.url.includes('api.openai.com')) ||
|
||||
($parameter.options?.baseURL && !$parameter.options?.baseURL?.startsWith('https://api.openai.com/')) ||
|
||||
($credentials?.url && !$credentials.url.startsWith('https://api.openai.com/')) ||
|
||||
$responseItem.id.startsWith('ft:') ||
|
||||
$responseItem.id.startsWith('o1') ||
|
||||
$responseItem.id.startsWith('o3') ||
|
||||
|
||||
@@ -15,8 +15,9 @@ export async function searchModels(
|
||||
const { data: models = [] } = await openai.models.list();
|
||||
|
||||
const filteredModels = models.filter((model: { id: string }) => {
|
||||
const url = baseURL && new URL(baseURL);
|
||||
const isValidModel =
|
||||
(baseURL && !baseURL.includes('api.openai.com')) ||
|
||||
(url && url.hostname !== 'api.openai.com') ||
|
||||
model.id.startsWith('ft:') ||
|
||||
model.id.startsWith('o1') ||
|
||||
model.id.startsWith('o3') ||
|
||||
|
||||
@@ -77,7 +77,8 @@ export async function modelSearch(
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const credentials = await this.getCredentials<{ url: string }>('openAiApi');
|
||||
const isCustomAPI = credentials.url && !credentials.url.includes('api.openai.com');
|
||||
const url = credentials.url && new URL(credentials.url);
|
||||
const isCustomAPI = url && url.hostname !== 'api.openai.com';
|
||||
|
||||
return await getModelSearch(
|
||||
(model) =>
|
||||
|
||||
@@ -64,14 +64,14 @@ export class CustomerIoApi implements ICredentialType {
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IHttpRequestOptions> {
|
||||
// @ts-ignore
|
||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
||||
if (url.includes('track') || url.includes('api.customer.io')) {
|
||||
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
||||
if (url.hostname === 'track.customer.io' || url.hostname === 'api.customer.io') {
|
||||
const basicAuthKey = Buffer.from(
|
||||
`${credentials.trackingSiteId}:${credentials.trackingApiKey}`,
|
||||
).toString('base64');
|
||||
// @ts-ignore
|
||||
Object.assign(requestOptions.headers, { Authorization: `Basic ${basicAuthKey}` });
|
||||
} else if (url.includes('beta-api.customer.io')) {
|
||||
} else if (url.hostname === 'beta-api.customer.io') {
|
||||
// @ts-ignore
|
||||
Object.assign(requestOptions.headers, {
|
||||
Authorization: `Bearer ${credentials.appApiKey as string}`,
|
||||
|
||||
@@ -27,8 +27,8 @@ export class MindeeInvoiceApi implements ICredentialType {
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IHttpRequestOptions> {
|
||||
// @ts-ignore
|
||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
||||
if (url.includes('https://api.mindee.net/v1/')) {
|
||||
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
||||
if (url.hostname === 'api.mindee.net' && url.pathname.startsWith('/v1/')) {
|
||||
requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`;
|
||||
} else {
|
||||
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
||||
|
||||
@@ -27,8 +27,8 @@ export class MindeeReceiptApi implements ICredentialType {
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IHttpRequestOptions> {
|
||||
// @ts-ignore
|
||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
||||
if (url.includes('https://api.mindee.net/v1/')) {
|
||||
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
||||
if (url.hostname === 'api.mindee.net' && url.pathname.startsWith('/v1/')) {
|
||||
requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`;
|
||||
} else {
|
||||
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
||||
|
||||
Reference in New Issue
Block a user