I ended up adding a sanity check: Fetch file URLs if they point to an image, otherwise fetch any image from the pasteboard, unless the pasteboard also contains objects of pasteboard type “fileURL”. Seems to work well enough.
Why is this step necessary? mastodon.technology might not be the server where you are registered, so we need to redirect you to your home server first.
Don't have an account? You can sign up here