Auto fill URL title feature isn't reliable

Testing version: 2.0 (10084)

What were you doing: paste external HTTP links into notes

What feature did you use: “Auto fill title when pasting web addresses”

What happened: sometimes Bear doesn’t replace URL with webpage’s title

What did you expect to happen: URLs should always be replaced with its title

To reproduce go to e.g. Wikipedia, the free encyclopedia
Keep follow random links and paste them into Bear.
Every 5-10 tries Bear pastes full URL instead of [title](URL) in my case

I suppose that issue is related to the time it takes to make HTTP request and get first few data chunks of the page’s HTML to extract the <title> tag. Probably the timeout for that request in Bear is too low (like 100ms) so depending on the internet connection, it won’t be enough sometimes.

Also I noticed that when the link isn’t replaced with title link, I paste it again and the second time it works. So maybe it’s also some sort of race condition.

Yes, it’s possible Bear is not fast enough to fetch the page title in time for when you paste the link. I’ll check again for possible mistakes but we are aware the above can happen in the conditions you mentioned (slow connection, slow webserver, private page, …).

I hit this private page scenario fairly often (ex. pasting links to private Google docs). Bear attempts to be smart here by not rendering titles if it hits a 404 (ex. links to private repositories on GitHub.com), but fails when the pasted URL redirects to some login page. You then get some title text that isn’t useful. I wonder if another level of heuristic is to just not attempt title fetching if any kind of redirect is encountered. I’d imagine most links folks are pasting in are “authoritative” and aren’t expected to hit redirects. Obviously that isn’t 100% true, but there is no solving for this area 100% since it is heuristics based. But, I thought it might be worth thinking about.