Skip to content

Commit

Permalink
feat: add owner/name format to search
Browse files Browse the repository at this point in the history
  • Loading branch information
nethriis committed Jan 21, 2025
1 parent 037e46d commit a829745
Show file tree
Hide file tree
Showing 7 changed files with 7,648 additions and 41 deletions.
13 changes: 1 addition & 12 deletions composables/inputUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,8 @@ export function useInputValidation(
}
}

const isValidUrl = (repositoryUrl: string) => {
const prefixes = [
'https://www.github.com/',
'https://github.com/',
'www.github.com/',
'github.com/'
]
return prefixes.some((prefix) => repositoryUrl.startsWith(prefix))
}

return {
onInput,
validateInput,
isValidUrl
validateInput
}
}
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export default defineNuxtConfig({

plugins: ['~/plugins/vercel-analytics.ts'],
compatibilityDate: '2024-10-22'
})
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"@vueuse/core": "^10.9.0",
"axios": "^1.7.7",
"primevue": "^3.49.1"
}
},
"packageManager": "pnpm@9.15.4"
}
24 changes: 7 additions & 17 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useInputValidation } from '@/composables/inputUtils'
import { useToastNotification } from '@/composables/useToast'
const pending = ref(false)
const repositoryUrl = ref('')
const repository = ref('')
const firstCommit = ref<any | null>(null)
const status = ref<number>(0)
Expand All @@ -19,8 +19,8 @@ const errorMessage = ref('')
const showToastStatus = ref(false)
const toastStatus = ref('')
const { onInput, validateInput, isValidUrl } = useInputValidation(
repositoryUrl,
const { onInput, validateInput } = useInputValidation(
repository,
validationError,
showRequired,
errorMessage
Expand Down Expand Up @@ -48,9 +48,7 @@ const fetchData = async (repositoryUrl: string) => {
}
}
const isSubmitDisabled = computed(() => {
return !repositoryUrl.value.trim()
})
const isSubmitDisabled = computed(() => !repository.value.trim())
</script>

<template>
Expand All @@ -76,13 +74,11 @@ const isSubmitDisabled = computed(() => {
<div class="flex space-x-2">
<input
type="text"
v-model="repositoryUrl"
v-model="repository"
@input="onInput"
@blur="validateInput"
@keydown.enter.prevent="
isSubmitDisabled || !isValidUrl(repositoryUrl)
? null
: fetchData(repositoryUrl)
isSubmitDisabled ? null : fetchData(repository)
"
name="repositoryUrl"
id="repositoryUrl"
Expand All @@ -96,13 +92,7 @@ const isSubmitDisabled = computed(() => {
</div>
<button
:disabled="isSubmitDisabled"
@click.prevent="
() => {
if (isValidUrl(repositoryUrl)) {
fetchData(repositoryUrl)
}
}
"
@click.prevent="() => fetchData(repository)"
class="w-12 justify-center items-center bg-black dark:bg-amber-50 hover:bg-slate-900 text-white py-1 px-3 cursor-pointer rounded-lg"
>
<div v-if="pending">
Expand Down
Loading

0 comments on commit a829745

Please sign in to comment.