tutanota
tutanota copied to clipboard
fix: export full contact urls instead of vanity urls
Problem
Exporting Vanity URLs
You accept both vanity URLs and full URLs for the default social media IDs. However, when a vanity URL is used, i.e. TutanotaTeam
instead of https://www.twitter.com/TutanotaTeam
, Tutanota currently doesn't populate it as a URL for the vCard export.
There should be consistency with how the URLs appear on the web client vs the vCard export. So for example if the web client will allow TutanotaTeam
as a Twitter handle and convert it to a URL, then in the export I'd expect to see the same URL that client produces.
Malformed URL in Export
The URL is malformed as the :
should not be escaped.
URL:http://example.org/restaurant.french/~chezchic.html
— https://datatracker.ietf.org/doc/html/rfc6350#section-6.7.8
Before the export looked like: URL:https\://www.twitter.com/SethFalco
Now it'll look correct: URL:https://www.twitter.com/SethFalco
In all other cases, escaping MUST NOT be used.
— https://datatracker.ietf.org/doc/html/rfc6350#section-3.4
It explicitly states that outside of the specified scenarios, don't escape things, of which colon (:
) is not one of the specified scenarios.
Changes
- Call
#getSocialUrl
when exporting URLs to a vCard string as well. - Pull
#getSocialUrl
out intoContactUtils.ts
and refactor it. - Fixed bug where having a URL with
http
but notwww
created a link like:www.http://example.org
. - A few minor import/doc changes, but nothing functional.
- A lot of tests weren't really testing things properly because of mismatching URLs vs social IDs. For example,
diaspora.de
obviously isn't a Twitter handle, but was being tested as one. With the fixes to actually export URLs instead of handles, the tests would've incorrected generated a Twitter URL instead of just prefixinghttps://www.
.
Just out of curiosity, may I ask why Tutanota opted to implement this themselves instead of using a library?
And if for whatever reason you feel the need to implement this yourself, thoughts about encapsulating it into its own library instead of having it directly in the project?
If you don't want to maintain it in a separate repo, this is one of those times where a monorepo could come in handy imo, so you can still separate components/libraries.
Hi, thank you for the change, hopefully we can get to reviewing it soon!
The VCard code is ancient, it might be that there was no good library at the moment. It would totally make sense as a module (we started to modularize explicitly some time ago and we have a few now).
Test Notes:
for each of the social link types except for "Other" and "Custom":
- [x] (1) a full account URL (like https://www.facebook.com/someguy) entered into the field can be visited by clicking the button
- [x] (2) a full account URL entered into the field is exported correctly into a vCard (meaning, when imported in google contacts or tutanota, the URL is not broken. Type will get lost.)
- [x] 1 and 2 also work for URLs that don't have the https:// prefix
- [x] 1 and 2 also work for URLs that don't have the www. prefix
- [x] 1 and 2 also work for a vanity URL (plain user name)
for "Other" and "Custom":
- [x] a full URL entered into the field is exported correctly and can be imported in an unbroken state
- [x] it can also be visited by clicking the button