View Single Post
Old 2018-02-10, 03:28 PM   #4
sarettah
Asleep at the switch? I wasn't asleep, I was drunk
 
Join Date: Apr 2005
Posts: 214
They are scheme relative urls.

https://stackoverflow.com/questions/...-relative-urls

Quote:
Scheme relative URLs (network-path references) are something that I've just found out about - where you don't specify the scheme of a URL and it picks it up from the current context.

For example: <img src="//domain.com/img.png" /> will resolve to https://domain.com/img.png if the current scheme is HTTPS or http://domain.com/img.png if it is not.

This seems like a very easy way to resolve those pesky problems of calling an external script or image on an SSL page without bringing up the dreaded error that some content on a page is not secure.

The benefit seems obvious, but what I don't seem to be able to find is a huge amount of information on this and was wondering if anyone had any experience or references about scheme relative URLs (good or bad)?


This article references an article from 2010 telling people to use scheme ralative but was updated in 2016 to tell you why it is bad to use them:

https://jeremywagner.me/blog/stop-us...-relative-url/

Quote:
Paul Irish has since changed his stance, and now advises against using this URL scheme to reference cross-origin resources. His rationale is that while using the scheme on HTTPS pages is safe, the reverse is not true. Using the scheme on a non-secure page will retrieve cross-origin assets in a non-secure fashion. This isn't good, and it's rather easy to just slap an https:// protocol on your URLs to ensure that your site is completely secure.

.
sarettah is offline   Reply With Quote