diff --git a/src/client/ContentClient.ts b/src/client/ContentClient.ts index d310175..2826bb4 100644 --- a/src/client/ContentClient.ts +++ b/src/client/ContentClient.ts @@ -76,13 +76,9 @@ export async function downloadContent( ) } -function sanitizeUrlWithContentPath(url: string): string { - return sanitizeUrl(url, '/content') -} - export function createContentClient(options: ClientOptions): ContentClient { const { fetcher, logger } = options - const contentUrl = sanitizeUrlWithContentPath(options.url) + const contentUrl = sanitizeUrl(options.url) const defaultParallelConfig = options?.parallelConfig async function fetchFromMultipleServersRace( @@ -102,7 +98,7 @@ export function createContentClient(options: ClientOptions): ContentClient { urls.forEach(async (url) => { try { - const serverUrl = sanitizeUrlWithContentPath(url) + const serverUrl = sanitizeUrl(url) const response = await fetcher.fetch(`${serverUrl}${path}`, requestOptionsWithSignal) if (signal.aborted) { @@ -148,7 +144,7 @@ export function createContentClient(options: ClientOptions): ContentClient { const results = await Promise.allSettled( urls.map(async (url) => { try { - const serverUrl = sanitizeUrlWithContentPath(url) + const serverUrl = sanitizeUrl(url) const response = await fetcher.fetch(`${serverUrl}${path}`, requestOptions) return await response.json() } catch (error) { diff --git a/src/client/LambdasClient.ts b/src/client/LambdasClient.ts index 8629837..73f7211 100644 --- a/src/client/LambdasClient.ts +++ b/src/client/LambdasClient.ts @@ -1,12 +1,12 @@ -import * as client from './specs/lambdas-client' +import { sanitizeUrl } from './utils/Helper' import { ClientOptions } from './types' import { CustomClient } from './utils/fetcher' -import { sanitizeUrl } from './utils/Helper' +import * as client from './specs/lambdas-client' export type LambdasClient = ReturnType export function createLambdasClient(options: ClientOptions) { - const lambdasUrl = sanitizeUrl(options.url, '/lambdas') + const lambdasUrl = sanitizeUrl(options.url) function wrap CustomClient>(f: T) { return (...args: Parameters): ReturnType> => { diff --git a/src/client/utils/Helper.ts b/src/client/utils/Helper.ts index 7778d49..40a30b4 100644 --- a/src/client/utils/Helper.ts +++ b/src/client/utils/Helper.ts @@ -221,7 +221,7 @@ function isValidQueryParamValue(value: any): boolean { } /** Remove white spaces and add https if no protocol is specified */ -export function sanitizeUrl(url: string, ensurePathPrefix?: string): string { +export function sanitizeUrl(url: string): string { // Remove empty spaces url = url.trim() @@ -235,10 +235,6 @@ export function sanitizeUrl(url: string, ensurePathPrefix?: string): string { url = url.slice(0, -1) } - if (ensurePathPrefix && !url.endsWith(ensurePathPrefix)) { - url += ensurePathPrefix - } - return url }