Skip to content

Commit

Permalink
fix: improve web share with zero width space
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Feb 1, 2024
1 parent 71b54cb commit 13e3649
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { joinURL, withoutLeadingSlash, parseURL } from 'ufo'
const route = useRoute()
const domain = computed(() => withoutLeadingSlash(route.path).toLowerCase().replace(/(\/|\?).*$/, '').trim())
const canonicalURL = computed(() => domain.value ? joinURL(`https://page-speed.dev`, domain.value) : 'https://page-speed.dev')
if (domain.value && !/^[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/g.test(domain.value)) {
throw new Error('Invalid domain')
Expand Down Expand Up @@ -136,16 +137,14 @@ useHead({
]
})
useServerHead({
htmlAttrs: {
lang: 'en',
},
link: [
{
rel: 'canonical',
href: joinURL(`https://page-speed.dev`, domain.value)
href: canonicalURL.value
},
{
rel: 'apple-touch-icon',
Expand Down Expand Up @@ -174,13 +173,8 @@ useServerHead({
]
})
useServerSeoMeta({
ogUrl: joinURL(`https://page-speed.dev`, domain.value)
})
useSeoMeta({
title: () => domain.value ? `page-speed.dev - ${domain.value}` : 'page-speed.dev',
})
useServerSeoMeta({ ogUrl: canonicalURL.value })
useSeoMeta({ title: () => domain.value ? `page-speed.dev - ${domain.value}` : 'page-speed.dev' })
if (!domain.value) {
defineOgImageComponent('Home')
Expand Down Expand Up @@ -213,15 +207,15 @@ function navigateToNewDomain () {
return navigateTo('/' + withoutLeadingSlash(host).toLowerCase().replace(/(\/|\?).*$/, '').trim())
}
const shareLink = computed(() => domain.value ? `https://twitter.com/intent/tweet?text=${encodeURIComponent(`Check out the Page Speed results for ${domain.value.replace(/\./g, '.\x00')}` + `\n\nhttps://page-speed.dev/${domain.value}`)}` : 'See and share PageSpeed Insights results simply and easily.')
const shareLink = computed(() => domain.value ? `https://twitter.com/intent/tweet?text=${encodeURIComponent(`Check out the Page Speed results for ${domain.value.replace(/\./g, '.')}` + `\n\nhttps://page-speed.dev/${domain.value}`)}` : 'See and share PageSpeed Insights results simply and easily.')
async function nativeShare () {
try {
if (navigator.share) {
return await navigator.share({
title: 'page-speed.dev',
text: `See page speed results for ${domain.value.replace(/\./g, '.\x00')}`,
url: `https://page-speed.dev/${domain.value}`,
text: `See page speed results for ${domain.value.replace(/\./g, '.')}`,
url: canonicalURL.value,
})
}
} catch {
Expand Down

0 comments on commit 13e3649

Please sign in to comment.