Skip to content

Commit

Permalink
fix: address regression in entering github URL into search bar
Browse files Browse the repository at this point in the history
Signed-off-by: tylerslaton <[email protected]>
  • Loading branch information
tylerslaton committed Mar 25, 2024
1 parent 454feea commit 9289440
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ watch(() => [route.path, route.query], () => {
})
function submitSearch() {
navigateTo({ name: 'search', query: { q: searchTerm.value } })
// if searchTerm is a valid github URL, navigate to its tool page
if (/^(https?:\/\/)?(www\.)?github\.com\/[\w-]+\/[\w-]+(\/[\w-]+)*$/.test(searchTerm.value)) {
useRouter().push(`/${searchTerm.value.replace(/^https?:\/\//, '')}`)
} else {
navigateTo({ name: 'search', query: { q: searchTerm.value } })
}
}
</script>

Expand Down
1 change: 0 additions & 1 deletion src/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async function fetchData() {
}
const { tools, totalCount } = await results.json()
console.log(totalCount)
searchResults.value = tools
totalItems.value = totalCount
loading.value = false
Expand Down

0 comments on commit 9289440

Please sign in to comment.