From 45d4d92979319620c609dd7c4c55539d161d961a Mon Sep 17 00:00:00 2001 From: Zaostrovskii Dmitrii Date: Tue, 20 Feb 2024 12:21:15 +0100 Subject: [PATCH] fix: refactoring --- libs/utils.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libs/utils.ts b/libs/utils.ts index cfe4603..b908bc1 100644 --- a/libs/utils.ts +++ b/libs/utils.ts @@ -15,21 +15,18 @@ export function getBasePath(alias: string, relativePath: string): string { export function pruneEmptyQueryParams(url: string): string { const querySeparator = '?'; - const queryParametersSeparator = '&'; + const queryParamsSeparator = '&'; if (!url || !url.includes(querySeparator)) { return url; } - const splitedUrl = url.split(querySeparator); - - const path = splitedUrl[0]; - const query = splitedUrl[1]; + const [path, query] = url.split(querySeparator); const prunedQuery = query - .split(queryParametersSeparator) + .split(queryParamsSeparator) .filter((x) => !x.trimEnd().endsWith('=')) - .join(queryParametersSeparator) + .join(queryParamsSeparator) .slice(0); return prunedQuery.length ? `${path}${querySeparator}${prunedQuery}` : path;