mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
fix: use slice instead of splice to avoid modifying value of environment variable
This commit is contained in:
@@ -35,7 +35,7 @@ export const baseOptions = (
|
||||
name: string,
|
||||
resources: Resource[],
|
||||
timeout: number = Env.DEFAULT_TIMEOUT,
|
||||
baseUrls?: string[]
|
||||
baseUrls?: readonly string[]
|
||||
): Option[] => {
|
||||
const urlOption: Option = {
|
||||
id: 'url',
|
||||
@@ -55,7 +55,7 @@ export const baseOptions = (
|
||||
label: baseUrls[0],
|
||||
value: 'undefined',
|
||||
},
|
||||
...baseUrls.splice(1).map((url) => ({
|
||||
...baseUrls.slice(1).map((url) => ({
|
||||
label: url,
|
||||
value: url,
|
||||
})),
|
||||
|
||||
@@ -92,7 +92,7 @@ const namedRegexes = makeValidator((x) => {
|
||||
const removeTrailingSlash = (x: string) =>
|
||||
x.endsWith('/') ? x.slice(0, -1) : x;
|
||||
|
||||
const presetUrls = makeExactValidator<string[]>((x) => {
|
||||
const presetUrls = makeExactValidator<readonly string[]>((x) => {
|
||||
if (typeof x !== 'string') {
|
||||
throw new EnvError('Preset URLs must be a string or an array of strings');
|
||||
}
|
||||
@@ -111,10 +111,10 @@ const presetUrls = makeExactValidator<string[]>((x) => {
|
||||
'Preset URLs must be an array of URLs or a single URL'
|
||||
);
|
||||
}
|
||||
return urls.map(removeTrailingSlash);
|
||||
return Object.freeze(urls.map(removeTrailingSlash));
|
||||
} catch (e) {
|
||||
if (typeof x === 'string' && validateUrl(x)) {
|
||||
return [removeTrailingSlash(x)];
|
||||
return Object.freeze([removeTrailingSlash(x)]);
|
||||
}
|
||||
throw new EnvError('Preset URLs must be an array of URLs or a single URL');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user