implemented detection of iframe
elements referencing cdn.ampproject.org
Currently the logic, if one's detected is
- Strip the URL fragment
- Split on /
- Take element 5 as the domain name
- Take element 6 onwards as the path
- prepend https://
- Redirect to that value
In an ideal world, all origin sites would be HTTPS, but realistically that's not necessarily true. So, we really should make sure we trigger a redirect to the correct protocol.
Looking at Google's AMP cache documentation, it looks like we can tell from the URL though. If position 4 == s
then the origin is HTTPS, if not it's HTTP
Because /s follows the /c prefix, the document will be fetched from example.com using TLS.
So, we should include a check and set the protocol accordingly