Skip to content

Commit

Permalink
fix: improve error catching of outputYear() method
Browse files Browse the repository at this point in the history
  • Loading branch information
rnmeow committed Jan 22, 2024
1 parent eeb3c97 commit 06de5e8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/global/AppFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<NuxtLink to="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">
<NuxtImg
src="external/https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"
class="hover:rotate-6" format="webp" fit="cover" alt="CC BY-NC-SA 4.0"
class="hover:rotate-6" format="webp" alt="CC BY-NC-SA 4.0"
/>
</NuxtLink>
</p>
Expand All @@ -24,15 +24,15 @@
<NuxtImg
class="inline hover:rotate-6"
src="external/https://img.shields.io/badge/Cloudflare-f6821f?style=flat-square&logo=Cloudflare&logoColor=white"
fit="cover" type="image/svg" alt="Cloudflare badge"
type="image/svg" alt="Cloudflare badge"
/>
</NuxtLink>
<NuxtLink to="https://vercel.com" target="_blank" aria-label="Link to Vercel">
<NuxtImg
class="inline hover:rotate-6"
src="external/https://img.shields.io/badge/Vercel-000000?style=flat-square&logo=vercel&logoColor=white"
fit="cover" type="image/svg" alt="Vercel badge"
type="image/svg" alt="Vercel badge"
/>
</NuxtLink>
驅動
Expand All @@ -46,11 +46,12 @@
<script lang="ts">
export default {
methods: {
outputYear(origYear: number): string | undefined {
outputYear(startYear: number): string {
const thisYear: number = new Date().getFullYear()
if (thisYear !== origYear) return `${origYear}-${thisYear}`
else if (thisYear === origYear) return origYear.toString()
return undefined
if (startYear > thisYear) {
throw new Error('FATAL: The starting year cannot be later than this year!')
}
else return thisYear > startYear ? `${startYear}-${thisYear}` : startYear.toString()
}
}
}
Expand Down

0 comments on commit 06de5e8

Please sign in to comment.