Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: Make
getFullUrl
use URL constructor.
This function relied on some hacky heuristics to give its output, and if something was wrong with its input, the effect wasn't very clear. Now, - no more hacky heuristics -- the URL constructor (as polyfilled by `react-native-url-polyfill`) will apply appropriate rules to give the correct output, given an acceptable input, and - if something is wrong with the input, we get a clear "INVALID_URL" error. Note that this function will now throw errors in cases where it didn't before. This is better than giving a (maybe subtly) wrong output, but it does suggest we should do some stress-testing with real data to be sure we weren't somehow taking advantage of the implementation mistakes that were there before. So, do that here. On CZO, I didn't encounter any INVALID_URL errors, even in the following likely-looking places: - Copying an in-message link to the clipboard -- both a relative upload URL and an absolute non-upload URL (Jitsi) - Avatar URLs in several places - Realm icon on the AuthScreen on CZO - Both links on LegalScreen The new implementation of `getFullUrl` is so simple that it'll be more transparent to inline it at all call sites, which we'll do in the next commit.
- Loading branch information