Skip to content

Commit bd9b041

Browse files
committed
fix: add provider param only for npm
1 parent e181dd2 commit bd9b041

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

app/components/Header/SearchBox.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ function updateUrlQueryImpl(value: string) {
4141
return
4242
}
4343
if (route.name === 'search') {
44-
router.replace({ query: { q: value || undefined, p: searchProviderValue.value } })
44+
router.replace({
45+
query: { q: value || undefined, p: searchProviderValue.value === 'npm' ? 'npm' : undefined },
46+
})
4547
return
4648
}
4749
if (!value) {
@@ -52,7 +54,7 @@ function updateUrlQueryImpl(value: string) {
5254
name: 'search',
5355
query: {
5456
q: value,
55-
p: searchProviderValue.value,
57+
p: searchProviderValue.value === 'npm' ? 'npm' : undefined,
5658
},
5759
})
5860
}

app/components/SearchProviderToggle.client.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ useEventListener('keydown', event => {
9090
@click="
9191
() => {
9292
searchProvider = 'algolia'
93-
router.push({ query: { ...route.query, p: 'algolia' } })
93+
router.push({ query: { ...route.query, p: undefined } })
9494
isOpen = false
9595
}
9696
"

app/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function search() {
1212
if (!query) return
1313
await navigateTo({
1414
path: '/search',
15-
query: query ? { q: query, p: searchProvider.value } : undefined,
15+
query: query ? { q: query, p: searchProvider.value === 'npm' ? 'npm' : undefined } : undefined,
1616
})
1717
const newQuery = searchQuery.value.trim()
1818
if (newQuery !== query) {

app/pages/search.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const updateUrlPage = debounce((page: number) => {
3434
query: {
3535
...route.query,
3636
page: page > 1 ? page : undefined,
37-
p: searchProviderValue.value,
37+
p: searchProviderValue.value === 'npm' ? 'npm' : undefined,
3838
},
3939
})
4040
}, 500)

0 commit comments

Comments
 (0)