bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
11.28k stars 1.44k forks source link

URLs are not recognized if capital letters present (HTTPS://, Https://, example.Com) #6332

Open mcclure opened 3 days ago

mcclure commented 3 days ago

Steps to Reproduce

Go to bsky.social. Make a post and type on various lines:

  1. https://cnn.com
  2. cnn.com
  3. https://cnn.COM
  4. Https://cnn.com
  5. HTTPS://cnn.com
  6. CNN.COM
  7. cnn.Com

OBSERVED BEHAVIOR: 1, 2, and 3 are recognized as URLs and become blue links. 4-7 are not. EXPECTED BEHAVIOR: All of these should be recognized as valid URLs, because they are. The components in which the capital letters occur are not case sensitive:

Attachments

Examples in this thread

https://bsky.app/profile/testaccountgoaway.bsky.social/post/3lavuyyxke22z

What platform(s) does this occur on?

Android, Web (Desktop)

Device Info

Firefox 130.0.1 on Ubuntu Linux, bluesky app on Android 13

What version of the app are you using?

Android app version is 1.93.0

Additional Information

Impact: This is really frustrating on Android because I use the Google "GBoard" keyboard, which likes to capitalize random things without me meaning to.

khuddite commented 3 days ago

I will take a look at this

JustSNguyen commented 3 days ago

This looks like a problem with Atproto. The issue is that Atproto first checks if the link starts with "http" or not (case sensitively). If not, then Atproto will check if the top-level domain (.com, .net, ...) is valid. Unfortunately, the list of top-level domains that Atproto uses is from an npm package called tlds (https://www.npmjs.com/package/tlds). If you look at the code of this package, it lowercases all the top-level domains, so the URLs you mentioned will be considered invalid. https://github.com/bluesky-social/atproto/blob/c34426fc55e8b9f28d9b1d64eab081985d1b47b5/packages/api/src/rich-text/detection.ts#L45-L48

I have created a PR to fix that issue in Atproto here: https://github.com/bluesky-social/atproto/pull/3002