MCPcopy
hub / github.com/directus/directus / removeQueryFromPath

Function removeQueryFromPath

app/src/utils/remove-query-from-path.ts:8–19  ·  view source on GitHub ↗
(path: string, ...keys: string[])

Source from the content-addressed store, hash-verified

6 * @param keys - Query param keys to remove
7 */
8export function removeQueryFromPath(path: string, ...keys: string[]): string {
9 const [base, search] = path.split('?');
10 const queryParams = new URLSearchParams(search || '');
11
12 for (const key of keys) {
13 queryParams.delete(key);
14 }
15
16 const remaining = queryParams.toString();
17
18 return remaining ? `${base}?${remaining}` : base!;
19}

Calls 2

deleteMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected