Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

485 B
Raw Blame
import { type RouteMetaParams } from '@/spa/router/routeMeta';

export const mergeSearchParams = (params: RouteMetaParams, url: string): RouteMetaParams => {
  const [, rawSearch = ''] = url.split('?');
  const search = rawSearch.split('#')[0] ?? '';
  if (!search) return params;

  const next: RouteMetaParams = { ...params };
  const searchParams = new URLSearchParams(search);

  for (const [key, value] of searchParams.entries()) {
    next[key] ??= value;
  }

  return next;
};