stefanobartoletti / nuxt-social-share

Simple Social Sharing for Nuxt 3
https://stefanobartoletti.github.io/nuxt-social-share/
MIT License
106 stars 8 forks source link

The link with spaces didn't work properly when shared #185

Open medaminefh opened 3 weeks ago

medaminefh commented 3 weeks ago

Summary (generated):

Here is a brief summary of the provided text:

Environment details are listed, including operating system, Node version, Nuxt version, CLI version, and more.

A code snippet is shown, featuring the SocialShare component with a v-for loop rendering multiple networks.

The bug is described as an issue with sharing links that have spaces in them, which causes the link to be converted to normal text instead of displaying as a link.


Environment

Reproduction

<SocialShare
  v-for="network in ['facebook', 'whatsapp', 'instagram']"
  :key="network"
  :network="network"
>
  <template #icon><Icon name="mdi:${network}" /></template>
</SocialShare>

Describe the bug

The issue is with sharing a link that have spaces in it like https://domain.com/Fournitures%20création%20accessoires%20cheveux this will be converted to normal text instead of a link https://domain.com/Fournitures création accessoires cheveux leading to the wrong page

Additional context

No response

Logs

No response

stefanobartoletti commented 3 weeks ago

Thanks, but I don't understand clearly what is happening here. What does "normal text instead of a link" mean?

What do you expect to get, and what are you getting instead? Could you please better describe the whole situation?

Also, to better understand what is going on, it is always better to include a minimal demo with a reproducible issue. A github repository or a demo on stackblitz would be the optimal way to provide this.

medaminefh commented 3 weeks ago

I mean when the URL has spaces in it will appear like this at the URL tab https://domain.com/Fournitures%20création%20accessoires%20cheveux but when I share it on Fb for exp it will share it like this https://domain.com/Fournitures création accessoires cheveux.

Have a look at This link and try to share it on FB or any other platform

stefanobartoletti commented 3 weeks ago

I see, I am also experiencing the issue documented here #177, the right URL is not correctly generated.

I may need to investigate this further, meanwhile can you better document your proposed solution in the draft PR that you opened? And test it if possible?

stefanobartoletti commented 3 weeks ago

As a side note, you should avoid using whitespaces in your URLs, as it may lead to all sorts of strange behaviors, not just when sharing on social media (think about manually copy-pasting in an email), and even browsers could handle them ambiguously, like i.e. Firefox:

Screenshot_20240609_015238

I can still have a look at this issue and see if the solution you proposed could help mitigate the problem, but it would help only when using those buttons to share, not in every other case.

You should use different characters to separate words in URL, the most common solution is using hypens -, so the URL would be https://domain.com/Fournitures-création-accessoires-cheveux.

Some references:

https://webmasters.stackexchange.com/questions/32867/does-using-spaces-in-a-url-affect-seo https://stackoverflow.com/questions/497908/is-a-url-allowed-to-contain-a-space

(just the first thing that come out with a quick search, you can delve more if you want)