MCPcopy Create free account
hub / github.com/dailydotdev/apps / getSearchUrl

Function getSearchUrl

packages/shared/src/graphql/search.ts:446–470  ·  view source on GitHub ↗
(params: SearchUrlParams)

Source from the content-addressed store, hash-verified

444};
445
446export const getSearchUrl = (params: SearchUrlParams): string => {
447 const { id, query, provider = SearchProviderEnum.Posts } = params;
448 const searchParams = new URLSearchParams();
449
450 if (!provider) {
451 throw new Error('provider is required');
452 }
453
454 const externalSearchProvider = externalSearchProviders[provider];
455
456 if (provider !== SearchProviderEnum.Posts && !externalSearchProvider) {
457 searchParams.append('provider', provider);
458 }
459
460 if (id) {
461 searchParams.append('id', id);
462 } else if (query) {
463 searchParams.append('q', query);
464 }
465
466 const searchUrl = externalSearchProvider?.url || searchPageUrl;
467 const searchParamsString = searchParams.toString();
468
469 return `${searchUrl}${searchParamsString ? `?${searchParamsString}` : ''}`;
470};
471
472export type SearchSuggestion = {
473 id?: string;

Callers 7

SearchProviderSegmentsFunction · 0.90
SearchProviderNavbarFunction · 0.90
buildPostCommandFunction · 0.90
buildSeeAllCommandFunction · 0.90
buildFallthroughFunction · 0.90
getItemsFunction · 0.90
useSearchProviderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected