JeffreyCA / Apollo-ImprovedCustomApi

Use your own Reddit and Imgur API credentials in Apollo
368 stars 19 forks source link

Add support for resolving Reddit media share links #9

Closed mmshivesh closed 11 months ago

mmshivesh commented 11 months ago

There's a few occasional links with the following format:

https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2Fpdnxq8dj0w881.jpg

for example, in this comment which in their current form redirect to a random post from 12 years ago.

This PR adds support for replacing these links by a direct link to the image by performing the following:

  1. Adding a regex pattern for such links
  2. Replacing matching the direct image url
  3. Percent decoding the match
  4. Build a new NSURL and return this instead of the original URL
JeffreyCA commented 11 months ago

Looks good, appreciate the contribution!