(value: string, provider: 'npm' | 'algolia')
| 52 | |
| 53 | // Updates URL when search query changes (immediately for instantSearch or after Enter hit otherwise) |
| 54 | const updateUrlQueryImpl = (value: string, provider: 'npm' | 'algolia') => { |
| 55 | const isSameQuery = route.query.q === value && route.query.p === provider |
| 56 | // Don't navigate away from pages that use ?q for local filtering |
| 57 | if ((pagesWithLocalFilter.has(route.name as string) && place === 'content') || isSameQuery) { |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | if (route.name === 'search') { |
| 62 | router.replace({ |
| 63 | query: { |
| 64 | ...route.query, |
| 65 | q: value || undefined, |
| 66 | p: provider === 'npm' ? 'npm' : undefined, |
| 67 | }, |
| 68 | }) |
| 69 | return |
| 70 | } |
| 71 | router.push({ |
| 72 | name: 'search', |
| 73 | query: { |
| 74 | q: value, |
| 75 | p: provider === 'npm' ? 'npm' : undefined, |
| 76 | }, |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | const updateUrlQuery = debounce(updateUrlQueryImpl, SEARCH_DEBOUNCE_MS) |
| 81 |
no outgoing calls
no test coverage detected